Skip to content

Instantly share code, notes, and snippets.

@JennieJi
Last active July 5, 2016 09:46
Show Gist options
  • Save JennieJi/2978ea7d34c62eba6288cd753b9de533 to your computer and use it in GitHub Desktop.
Save JennieJi/2978ea7d34c62eba6288cd753b9de533 to your computer and use it in GitHub Desktop.
export function htmlEscape(content) {
[
{origin: '&', escaped: '&'},
{origin: '<', escaped: '&lt;'},
{origin: '>', escaped: '&gt;'}
].forEach(pair => content = content.replace(new RegExp(pair.origin, 'g'), pair.escaped));
return content;
}
@JennieJi
Copy link
Author

JennieJi commented Jul 5, 2016

I found it's not really necessary to escape single and double quote

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment