(s: string)
| 386 | } |
| 387 | |
| 388 | function decodeEntities(s: string): string { |
| 389 | return s.replace(/&(amp|lt|gt|quot|apos|#\d+|#x[0-9a-fA-F]+);/g, (_, ent) => { |
| 390 | switch (ent) { |
| 391 | case 'amp': |
| 392 | return '&' |
| 393 | case 'lt': |
| 394 | return '<' |
| 395 | case 'gt': |
| 396 | return '>' |
| 397 | case 'quot': |
| 398 | return '"' |
| 399 | case 'apos': |
| 400 | return "'" |
| 401 | default: |
| 402 | if (ent.startsWith('#x')) return String.fromCodePoint(Number.parseInt(ent.slice(2), 16)) |
| 403 | if (ent.startsWith('#')) return String.fromCodePoint(Number.parseInt(ent.slice(1), 10)) |
| 404 | return `&${ent};` |
| 405 | } |
| 406 | }) |
| 407 | } |
| 408 | |
| 409 | function localOf(name: string): string { |
| 410 | const idx = name.indexOf(':') |
no test coverage detected