const escapeHTML = (str: string) =>
str.replace(
/[&<>'"]/g,
tag =>
({
'&': '&',
'<': '<',
'>': '>',
"'": ''',
'"': '"'
}[tag] || tag)
);
Escape HTML
Escapes a string for use in HTML.
0 Comments
Add Comment
Log in to add a comment