mirror of
https://github.com/whoswhip/Sharpbin.git
synced 2026-12-06 02:48:43 +00:00
13 lines
261 B
TypeScript
13 lines
261 B
TypeScript
const htmlEscapeMap: Record<string, string> = {
|
|
'&': '&',
|
|
'<': '<',
|
|
'>': '>',
|
|
'"': '"',
|
|
"'": ''',
|
|
'`': '`'
|
|
};
|
|
|
|
export function escapeHtml(value: string): string {
|
|
return value.replace(/[&<>"'`]/g, (char) => htmlEscapeMap[char]);
|
|
}
|