choriakiinweill_tools
Version:
提供了格式化时间,转义html字符串的功能
39 lines (34 loc) • 702 B
JavaScript
//导出函数,向外暴露需要的成员
//转义html模块
function htmlEscape(htmlStr) {
return htmlStr.replace(/<|>|"&/g, (match) => {
switch (match) {
case '<':
return '<'
case '>':
return '>'
case '"':
return '"'
case '&':
return '&'
}
})
}
function htmlUnEscape(str) {
return str.replace(/<|>|"|&/g, (match) => {
switch (match) {
case '<':
return '<'
case '>':
return '>'
case '"':
return '"'
case '&':
return '&'
}
})
}
module.exports = {
htmlEscape,
htmlUnEscape
}