Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
replace uncode to special char in Javascript
entityMap : {
'&': '&',
'<': '&lt;',
'>': '&gt;',
//'"': '&quot;',
//"'": '&#39;',
//'/': '&#x2F;',
//'`': '&#x60;',
'=': '&#x3D;'
},
escapeHtml(string) {
return String(string).replace(/[&<>"'`=\/]/g, function (s) {
return PromotionJS.entityMap[s];
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment