(entity: string, body: string)
| 344 | } |
| 345 | |
| 346 | function decodeNumericXmlEntity(entity: string, body: string): string { |
| 347 | const codePoint = body.startsWith('#x') |
| 348 | ? Number.parseInt(body.slice(2), 16) |
| 349 | : Number(body.slice(1)); |
| 350 | if (!Number.isInteger(codePoint) || codePoint < 0 || codePoint > 0x10ffff) { |
| 351 | return entity; |
| 352 | } |
| 353 | try { |
| 354 | return String.fromCodePoint(codePoint); |
| 355 | } catch { |
| 356 | return entity; |
| 357 | } |
| 358 | } |
no test coverage detected