17 lines
431 B
TypeScript
17 lines
431 B
TypeScript
export const escapeHTML = (unsafe: string) => {
|
|
return unsafe
|
|
.replaceAll("&", "&")
|
|
.replaceAll("<", "<")
|
|
.replaceAll(">", ">")
|
|
.replaceAll('"', """)
|
|
.replaceAll("'", "'")
|
|
}
|
|
|
|
export const unescapeHTML = (html: string) => {
|
|
return html
|
|
.replaceAll("&", "&")
|
|
.replaceAll("<", "<")
|
|
.replaceAll(">", ">")
|
|
.replaceAll(""", '"')
|
|
.replaceAll("'", "'")
|
|
}
|