export const funEncodeHTML = function (str) {
if (typeof str === 'string') {
return str.replace(/<|&|>/g, (matches) => {
const res = ({
'<': '<',
'>': '>',
'&': '&',
})[matches];
return res ?? '';
});
}
return '';
};
xss 转义
阅读 210
2022-12-10
export const funEncodeHTML = function (str) {
if (typeof str === 'string') {
return str.replace(/<|&|>/g, (matches) => {
const res = ({
'<': '<',
'>': '>',
'&': '&',
})[matches];
return res ?? '';
});
}
return '';
};
相关推荐
精彩评论(0)