From 16893b52b141938a32027049b71cc6c6f46dfb93 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Sun, 19 Apr 2020 10:18:31 -0400 Subject: Make getFileNameExtension properly handle directory separators --- ext/bg/js/media-utility.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'ext/bg') 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': -- cgit v1.2.3