Skip to content

Instantly share code, notes, and snippets.

@jmosbech
Last active December 12, 2015 07:08
Show Gist options
  • Save jmosbech/4734008 to your computer and use it in GitHub Desktop.
Save jmosbech/4734008 to your computer and use it in GitHub Desktop.
first go at a filename santitizer that supports non ascii chars
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