zyheima36
Version:
格式化时间,HTMLEscape相关的功能,更新了现旧版本的index.js的bug问题
37 lines (36 loc) • 923 B
JavaScript
// 对特殊符号转换
function htmlchange(htmlStr) {
// g代表全局匹配,| 代表 或者
return htmlStr.replace(/<|>|"|&/g, function (my) {
switch (my) {
case ">":
return ">"
case "<":
return "<"
case '"':
return """
case "&":
return "&"
}
})
}
// 再把特殊符号转换回来原来的样式
function rehtml(ht) {
return ht.replace(/>|<|"|&/g, function (remy) {
switch (remy) {
case ">":
return ">"
case "<":
return "<"
case '"':
return '"'
case "&":
return "&"
}
})
}
// 把数据暴露出来,供吉他模块使用
module.exports = {
htmlchange,
rehtml
}