Make getFileNameExtension properly handle directory separators

This commit is contained in:
toasted-nutbread 2020-04-19 10:18:31 -04:00
parent 7faaf4e457
commit 16893b52b1

View File

@ -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':