UNPKG

mr_cao

Version:

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

34 lines 696 B
// 定义转移html的函数 function htmlEscape(htmlstr) { return htmlstr.replace(/<|>|&|'"'/g,function(match){ switch(match) { case '<': return '&git' case '>': return '&gt' case '&': return '&amp' case '"': return '&quot' } }) } // 定义还原html的方法 function htmlUnEscape(htmlstr) { return htmlstr.replace(/&git|&gt|&amp|'&quot'/g,function(match){ switch(match) { case '&git': return '<' case '&gt': return '>' case '&amp': return '&' case '&quot': return '"' } }) } module.exports = { htmlEscape, htmlUnEscape }