UNPKG

lxyyy

Version:

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

33 lines (32 loc) 571 B
function htmlEscape(htmlStr) { return htmlStr.replace(/<|>|"|&/g, function(match) { switch (match) { case '<': return '&lt;' case '>': return '&gt;' case '"': return '&quto;' case '&': return '&amp;' } }) } function htmlUnEscape(htmlStr) { return htmlStr.replace(/&lt;|&gt;|&quto;|&amp;/g, function(match) { switch (match) { case '&lt;': return '<' case '&gt;': return '>' case '&quto;': return '"' case '&amp;': return '&' } }) } module.exports = { htmlEscape, htmlUnEscape }