mirror of
https://github.com/whoswhip/Sharpbin.git
synced 2026-12-06 02:48:43 +00:00
refactor: remove duplicate escape functions; improve escapeHtml function
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
const htmlEscapeMap: Record<string, string> = {
|
||||
'&': '&',
|
||||
'<': '<',
|
||||
'>': '>',
|
||||
'"': '"',
|
||||
"'": ''',
|
||||
'`': '`'
|
||||
};
|
||||
|
||||
export function escapeHtml(value: string): string {
|
||||
return value.replace(/[&<>"'`]/g, (char) => htmlEscapeMap[char]);
|
||||
}
|
||||
Reference in New Issue
Block a user