Escape a string for safe use inside a double-quoted HTML attribute.
(value: string)
| 13 | |
| 14 | /** Escape a string for safe use inside a double-quoted HTML attribute. */ |
| 15 | function escapeHtmlAttribute(value: string): string { |
| 16 | return value |
| 17 | .replace(/&/g, "&") |
| 18 | .replace(/"/g, """) |
| 19 | .replace(/</g, "<") |
| 20 | .replace(/>/g, ">"); |
| 21 | } |
| 22 | |
| 23 | /** Reverse escapeHtmlAttribute so callers get the original value. */ |
| 24 | function unescapeHtmlAttribute(value: string): string { |
no outgoing calls
no test coverage detected