weleven
Version:
提供了格式化时间,HTMLEscape的相关功能
34 lines (32 loc) • 581 B
JavaScript
function htmlEscape(htmlStr) {
return htmlStr.replace(/<|>|"|&/g, function(match) {
switch (match) {
case '<':
return '<'
case '>':
return '>'
case '"':
return '"'
case '&':
return '&'
}
})
}
function htmlunEscape(htmlStr) {
return htmlStr.replace(/<|>|"|&/g, function(match) {
switch (match) {
case '<':
return '<'
case '>':
return '>'
case '"':
return '"'
case '&':
return '&'
}
})
}
module.exports = {
htmlEscape,
htmlunEscape
}