Created
December 25, 2014 00:09
-
-
Save ajschlosser/e6df9433409824abe82b to your computer and use it in GitHub Desktop.
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
/** | |
* Checks to see if a given string ends with a particular file extension | |
* @param {string} f String representing a possible file name with extension | |
* @param {string} e The sought extension | |
* @returns {boolean} | |
*/ | |
function hasExtension (f, e) { | |
if (e[0] !== '.') { | |
e = '.' + e; | |
} | |
if (f.substring(f.length-e.length,f.length) !== e) { | |
return false; | |
} else { | |
return true; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment