We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent a14e493 commit 5e703b6Copy full SHA for 5e703b6
src/js/utils/url.js
@@ -47,14 +47,12 @@ export const getAbsoluteURL = function(url) {
47
*/
48
export const getFileExtension = function(path) {
49
if (typeof path === 'string') {
50
- const splitPathRe = /^(\/?)([\s\S]*?)((?:\.{1,2}|[^\/]+?)(\.*([^\.\/\?]+)))(?:[\/]*|[\?].*)$/;
51
- const pathParts = splitPathRe.exec(path);
+ const cleanPath = path.split('?')[0];
52
53
- if (pathParts) {
54
- return pathParts.pop().toLowerCase();
55
- }
56
+ const match = cleanPath.match(/\.([^.\/]+)$/);
57
+ return match ? match[1].toLowerCase() : '';
+ }
58
return '';
59
};
60
0 commit comments