MCPcopy Index your code
hub / github.com/monkeytypegame/monkeytype / escapeHTML

Function escapeHTML

frontend/src/ts/utils/misc.ts:130–146  ·  view source on GitHub ↗
(str: T)

Source from the content-addressed store, hash-verified

128}
129
130export function escapeHTML<T extends string | null | undefined>(str: T): T {
131 if (str === null || str === undefined) {
132 return str;
133 }
134
135 const escapeMap: Record<string, string> = {
136 "&": "&amp;",
137 "<": "&lt;",
138 ">": "&gt;",
139 '"': "&quot;",
140 "'": "&#39;",
141 "/": "&#x2F;",
142 "`": "&#x60;",
143 };
144
145 return str.replace(/[&<>"'/`]/g, (char) => escapeMap[char] as string) as T;
146}
147
148export function clearTimeouts(timeouts: (number | NodeJS.Timeout)[]): void {
149 timeouts.forEach((to) => {

Callers 2

toggleFunboxFunction · 0.90
misc.spec.tsFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected