Last active
December 12, 2015 07:08
-
-
Save jmosbech/4734008 to your computer and use it in GitHub Desktop.
first go at a filename santitizer that supports non ascii chars
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
function sanitizeFilename (filename){ | |
var blacklist = /[^\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF0-9a-z'\s\-_]/gi; | |
return filename.replace(blacklist, '').trim().substring(0, 200); // 200 should be more than enough, but still safe | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment