Skip to content

Instantly share code, notes, and snippets.

@baladkb
Created September 20, 2018 11:14
Show Gist options
  • Save baladkb/414abd412659d87f9a8021ef9feddbd1 to your computer and use it in GitHub Desktop.
Save baladkb/414abd412659d87f9a8021ef9feddbd1 to your computer and use it in GitHub Desktop.
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