Jon Erling Hustadnes
2026-01-05 5208a96a3768e92d203e3d2c6fd3a79e21be64be
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
export const escapeHTML = (unsafe: string) => {
  return unsafe
    .replaceAll("&", "&")
    .replaceAll("<", "&lt;")
    .replaceAll(">", "&gt;")
    .replaceAll('"', "&quot;")
    .replaceAll("'", "&#039;")
}
 
export const unescapeHTML = (html: string) => {
  return html
    .replaceAll("&amp;", "&")
    .replaceAll("&lt;", "<")
    .replaceAll("&gt;", ">")
    .replaceAll("&quot;", '"')
    .replaceAll("&#039;", "'")
}