bigly-chat/common/format.js

18 lines
276 B
JavaScript
Raw Normal View History

2024-09-07 18:12:58 -04:00
const escapeCodes = {
'&': '&',
'<': '&lt;',
'>': '&gt;',
"'": '&#39;',
'"': '&quot;'
};
let format = {};
format.escape = function (str) {
return str.replaceAll(
/[&<>'"]/g,
tag => escapeCodes[tag]
)
};
export default format;