Created
April 9, 2018 13:54
-
-
Save ArrayIterator/2019fbf431d937d8b30e50f6b1cc21e2 to your computer and use it in GitHub Desktop.
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 sanityHTMLClass = (str) => { | |
if (typeof str !== 'string') { | |
return ''; | |
} | |
return str | |
// replace for v?s?printf | |
.replace(/%[a-fA-F0-9][a-fA-F0-9]/, '') | |
// Limit to A-Z,a-z,0-9,_,- | |
.replace(/[^A-Za-z0-9_-]/, ''); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment