diff --git a/src/js/utils/url.js b/src/js/utils/url.js index a81da326f7..9a88824fea 100644 --- a/src/js/utils/url.js +++ b/src/js/utils/url.js @@ -47,14 +47,12 @@ export const getAbsoluteURL = function(url) { */ export const getFileExtension = function(path) { if (typeof path === 'string') { - const splitPathRe = /^(\/?)([\s\S]*?)((?:\.{1,2}|[^\/]+?)(\.*([^\.\/\?]+)))(?:[\/]*|[\?].*)$/; - const pathParts = splitPathRe.exec(path); + const cleanPath = path.split('?')[0]; - if (pathParts) { - return pathParts.pop().toLowerCase(); - } - } + const match = cleanPath.match(/\.([^.\/]+)$/); + return match ? match[1].toLowerCase() : ''; + } return ''; };