18 lines
No EOL
276 B
JavaScript
18 lines
No EOL
276 B
JavaScript
const escapeCodes = {
|
|
'&': '&',
|
|
'<': '<',
|
|
'>': '>',
|
|
"'": ''',
|
|
'"': '"'
|
|
};
|
|
|
|
let format = {};
|
|
|
|
format.escape = function (str) {
|
|
return str.replaceAll(
|
|
/[&<>'"]/g,
|
|
tag => escapeCodes[tag]
|
|
)
|
|
};
|
|
|
|
export default format; |