(text: string)
| 163 | * @returns The text with special characters encoded as entities. |
| 164 | */ |
| 165 | export function encodeEntities(text: string): string { |
| 166 | // Fast path: no special characters means nothing to encode |
| 167 | if (!/[<>&'"]/.test(text)) return text; |
| 168 | return text.replace(SPECIAL_CHARS_REGEXP, (c) => ENTITY_MAP[c]!); |
| 169 | } |
| 170 | |
| 171 | /** |
| 172 | * Encodes special characters for use in XML attribute values. |
no outgoing calls
no test coverage detected