cjlitheima-tools
Version:
提供了格式化时间,HTMLEscape的功能
39 lines (35 loc) • 859 B
JavaScript
//定义转义html字符的函数
function HTMLEscape(htmlStr) {
return htmlStr.replace(/<|>|"|&/g, match => {
switch (match) {
case '<':
return '<'
case '>':
return '>'
case '"':
return '"'
case '&':
return '&'
}
})
}
//定义还原html字符的函数
function htmlUnEscape(str) {
return str.replace(/<|>|"|&/g, match => {
switch (match) {
case '<':
return '<'
case '>':
return '>'
case '"':
return '"'
case '&':
return '&'
}
})
}
//暴露成员
module.exports = {
HTMLEscape,
htmlUnEscape
}