(segment: string)
| 528 | } |
| 529 | |
| 530 | function decodeSegment(segment: string): string { |
| 531 | let decoded: string |
| 532 | try { |
| 533 | decoded = decodeURI(segment) |
| 534 | } catch { |
| 535 | // if the decoding fails, try to decode the various parts leaving the malformed tags in place |
| 536 | decoded = segment.replaceAll(/%[0-9A-F]{2}/gi, (match) => { |
| 537 | try { |
| 538 | return decodeURI(match) |
| 539 | } catch { |
| 540 | return match |
| 541 | } |
| 542 | }) |
| 543 | } |
| 544 | return sanitizePathSegment(decoded) |
| 545 | } |
| 546 | |
| 547 | /** |
| 548 | * Default list of URL protocols to allow in links, redirects, and navigation. |
no test coverage detected