Skip to content

Instantly share code, notes, and snippets.

@seymores
Created March 17, 2015 03:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seymores/c4f793e953f7d8623acb to your computer and use it in GitHub Desktop.
Save seymores/c4f793e953f7d8623acb to your computer and use it in GitHub Desktop.
Function to sanitize image file name to be web safe.
var safeImageURI = function(s) { return encodeURI(s).replace(/\-/g, "%2D").replace(/\_/g, "%5F").replace(/\./g, "%2E").replace(/\!/g, "%21").replace(/\~/g, "%7E").replace(/\*/g, "%2A").replace(/\'/g, "%27").replace(/\(/g, "%28").replace(/\)/g, "%29"); }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment