UNPKG

itxiaoma-tools

Version:

提供格式化时间,HTMLEscape 相关功能

35 lines (32 loc) 659 B
// 转义 HTML 字符的函数 function htmlEscape(htmlStr) { return htmlStr.replace(/<|>|"|&/g, (match) => { switch (match) { case '<': return '&lt' case '>': return '&gt' case '"': return '&quot' } }) } // 还原 HTML 字符的函数 function htmlUnEscape(htmlStr) { return htmlStr.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 }