Created
December 20, 2016 08:53
-
-
Save nash403/7b888414231ea79a483239ad891dfdc1 to your computer and use it in GitHub Desktop.
An efficient way to get a file extension from the file's name
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Does not handle hidden files like .htaccess the way you would want though ;) | |
getFileExtension (filename) { | |
let res = filename.substr(filename.lastIndexOf('.')+1); | |
return res === filename ? '' : res; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment