Last active
July 5, 2016 09:46
-
-
Save JennieJi/2978ea7d34c62eba6288cd753b9de533 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
export function htmlEscape(content) { | |
[ | |
{origin: '&', escaped: '&'}, | |
{origin: '<', escaped: '<'}, | |
{origin: '>', escaped: '>'} | |
].forEach(pair => content = content.replace(new RegExp(pair.origin, 'g'), pair.escaped)); | |
return content; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I found it's not really necessary to escape single and double quote