UNPKG

weleven

Version:

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

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