mr_cao
Version:
提供格式化时间,HTMLEscape相关功能
34 lines • 696 B
JavaScript
// 定义转移html的函数
function htmlEscape(htmlstr) {
return htmlstr.replace(/<|>|&|'"'/g,function(match){
switch(match) {
case '<':
return '&git'
case '>':
return '>'
case '&':
return '&'
case '"':
return '"'
}
})
}
// 定义还原html的方法
function htmlUnEscape(htmlstr) {
return htmlstr.replace(/&git|>|&|'"'/g,function(match){
switch(match) {
case '&git':
return '<'
case '>':
return '>'
case '&':
return '&'
case '"':
return '"'
}
})
}
module.exports = {
htmlEscape,
htmlUnEscape
}