Make getFileNameExtension properly handle directory separators
This commit is contained in:
parent
7faaf4e457
commit
16893b52b1
@ -16,13 +16,13 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
const mediaUtility = (() => {
|
const mediaUtility = (() => {
|
||||||
function getFileNameExtension(fileName) {
|
function getFileNameExtension(path) {
|
||||||
const match = /\.[^.]*$/.exec(fileName);
|
const match = /\.[^./\\]*$/.exec(path);
|
||||||
return match !== null ? match[0] : '';
|
return match !== null ? match[0] : '';
|
||||||
}
|
}
|
||||||
|
|
||||||
function getImageMediaTypeFromFileName(fileName) {
|
function getImageMediaTypeFromFileName(path) {
|
||||||
switch (getFileNameExtension(fileName).toLowerCase()) {
|
switch (getFileNameExtension(path).toLowerCase()) {
|
||||||
case '.apng':
|
case '.apng':
|
||||||
return 'image/apng';
|
return 'image/apng';
|
||||||
case '.bmp':
|
case '.bmp':
|
||||||
|
Loading…
Reference in New Issue
Block a user