UNPKG

kukudebai-tools

Version:

Learn to use tools.

36 lines (34 loc) 753 B
//string escape function htmlEscape(htmlStr) { return htmlStr.replace(/<|>|"|&/g, (match) => { switch (match) { case '<': return '&lt;' case '>': return '&gt;' case '"': return '&quot;' case '&': return '&amp' } }) } //un function htmlUnEscape(str){ return str.replace(/&lt;|&gt;|&quot;|&amp/g, (match) => { switch (match) { case '&lt;': return '<' case '&gt;': return '>' case '&quot;': return '"' case '&amp': return '&' } }) } module.exports = { htmlEscape, htmlUnEscape }