UNPKG

zyheima36

Version:

格式化时间,HTMLEscape相关的功能,更新了现旧版本的index.js的bug问题

37 lines (36 loc) 923 B
// 对特殊符号转换 function htmlchange(htmlStr) { // g代表全局匹配,| 代表 或者 return htmlStr.replace(/<|>|"|&/g, function (my) { switch (my) { case ">": return "&gt" case "<": return "&lt" case '"': return "&quot" case "&": return "&amp" } }) } // 再把特殊符号转换回来原来的样式 function rehtml(ht) { return ht.replace(/&gt|&lt|&quot|&amp/g, function (remy) { switch (remy) { case "&gt": return ">" case "&lt": return "<" case '&quot': return '"' case "&amp": return "&" } }) } // 把数据暴露出来,供吉他模块使用 module.exports = { htmlchange, rehtml }