zyz-tools-b
Version:
提供了格式化时间,HTMLEscape相关的功能
37 lines (34 loc) • 786 B
JavaScript
//定义转义
function htmlEscape(a) {
return a.replace(/<|>|"|&/g, match => {
switch (match) {
case '<':
return ">"
case '>':
return ">"
case '"':
return """
case '&':
return "&"
}
})
}
//定义还原
function htmlUnEscape(b) {
return b.replace(/>>"&/g, (match) => {
switch (match) {
case '>':
return "<"
case '>':
return ">"
case '"':
return '"'
case '&':
return "&"
}
})
}
module.exports = {
htmlEscape,
htmlUnEscape
}