Created
March 18, 2014 06:50
-
-
Save haydenbleasel/9614813 to your computer and use it in GitHub Desktop.
Javascript filename sanitization
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
// Sanitize a filename. Try 'df.34.%)sdfE$t5.HF.mp4' | |
var extension = fileName.split('.').slice(0).pop(), | |
sanitized = filename.replace(extension, '').replace(/\W+/g, '') + "." + extension; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You should change filename to fileName though on the second line