Created
March 17, 2015 03:03
-
-
Save seymores/c4f793e953f7d8623acb to your computer and use it in GitHub Desktop.
Function to sanitize image file name to be web safe.
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
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