Files
2026-04-13 08:19:53 +08:00

13 lines
224 B
JavaScript

const htmlEscapes = {
'&': '&',
'<': '&lt;',
'>': '&gt;',
'"': '&quot;',
"'": '&#39;',
};
function escape(str) {
return str.replace(/[&<>"']/g, match => htmlEscapes[match]);
}
export { escape };