13 lines
224 B
JavaScript
13 lines
224 B
JavaScript
const htmlEscapes = {
|
|
'&': '&',
|
|
'<': '<',
|
|
'>': '>',
|
|
'"': '"',
|
|
"'": ''',
|
|
};
|
|
function escape(str) {
|
|
return str.replace(/[&<>"']/g, match => htmlEscapes[match]);
|
|
}
|
|
|
|
export { escape };
|