mirror of
https://github.com/stack-auth/stack.git
synced 2026-06-13 21:01:21 +08:00
15 lines
423 B
TypeScript
15 lines
423 B
TypeScript
import { templateIdentity } from "./strings";
|
|
|
|
export function escapeHtml(unsafe: string): string {
|
|
return `${unsafe}`
|
|
.replace(/&/g, '&')
|
|
.replace(/</g, '<')
|
|
.replace(/>/g, '>')
|
|
.replace(/"/g, """)
|
|
.replace(/'/g, "'");
|
|
}
|
|
|
|
export function html(strings: TemplateStringsArray, ...values: any[]): string {
|
|
return templateIdentity(strings, ...values.map(v => escapeHtml(`${v}`)));
|
|
}
|