mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-11-16 21:08:17 +00:00
12 lines
375 B
TypeScript
12 lines
375 B
TypeScript
const HTML_ATTRIBUTE_ENTITIES: Readonly<Record<string, string>> = {
|
|
'&': '&',
|
|
'<': '<',
|
|
'>': '>',
|
|
'"': '"',
|
|
"'": ''',
|
|
};
|
|
|
|
/** Escapes text before interpolating it into a quoted HTML attribute. */
|
|
export function escapeHtmlAttribute(value: string): string {
|
|
return value.replace(/[&<>"']/g, (character) => HTML_ATTRIBUTE_ENTITIES[character]);
|
|
}
|