This commit is contained in:
2024-03-22 03:47:51 +05:30
parent 8bcf3d211e
commit 89819f6fe2
28440 changed files with 3211033 additions and 2 deletions

View File

@@ -0,0 +1,25 @@
/**
* react-loadable-ssr-addon
* @author Marcos Gonçalves <contact@themgoncalves.com>
* @version 1.0.1
*/
/**
* Get file extension
* @method getFileExtension
* @static
* @param {string} filename - File name
* @returns {string} - File extension
*/
function getFileExtension(filename) {
if (!filename || typeof filename !== 'string') { return ''; }
const fileExtRegex = /\.\w{2,4}\.(?:map|gz)$|\.\w+$/i;
const name = filename.split(/[?#]/)[0]; // eslint-disable-line prefer-destructuring
const ext = name.match(fileExtRegex);
return ext && ext.length ? ext[0] : '';
}
export default getFileExtension;