diff options
author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2020-04-19 10:18:31 -0400 |
---|---|---|
committer | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2020-04-19 10:18:31 -0400 |
commit | 16893b52b141938a32027049b71cc6c6f46dfb93 (patch) | |
tree | c6e0cc3120f80bb8bb633747e880890600646341 | |
parent | 7faaf4e45737dd06ab3fdf189bd9c1d26ad1349d (diff) |
Make getFileNameExtension properly handle directory separators
-rw-r--r-- | ext/bg/js/media-utility.js | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/ext/bg/js/media-utility.js b/ext/bg/js/media-utility.js index febc509a..8a46cb49 100644 --- a/ext/bg/js/media-utility.js +++ b/ext/bg/js/media-utility.js @@ -16,13 +16,13 @@ */ const mediaUtility = (() => { - function getFileNameExtension(fileName) { - const match = /\.[^.]*$/.exec(fileName); + function getFileNameExtension(path) { + const match = /\.[^./\\]*$/.exec(path); return match !== null ? match[0] : ''; } - function getImageMediaTypeFromFileName(fileName) { - switch (getFileNameExtension(fileName).toLowerCase()) { + function getImageMediaTypeFromFileName(path) { + switch (getFileNameExtension(path).toLowerCase()) { case '.apng': return 'image/apng'; case '.bmp': |