(str: T)
| 128 | } |
| 129 | |
| 130 | export 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 | "&": "&", |
| 137 | "<": "<", |
| 138 | ">": ">", |
| 139 | '"': """, |
| 140 | "'": "'", |
| 141 | "/": "/", |
| 142 | "`": "`", |
| 143 | }; |
| 144 | |
| 145 | return str.replace(/[&<>"'/`]/g, (char) => escapeMap[char] as string) as T; |
| 146 | } |
| 147 | |
| 148 | export function clearTimeouts(timeouts: (number | NodeJS.Timeout)[]): void { |
| 149 | timeouts.forEach((to) => { |
no outgoing calls
no test coverage detected