MCPcopy
hub / github.com/TanStack/router / decodeSegment

Function decodeSegment

packages/router-core/src/utils.ts:530–545  ·  view source on GitHub ↗
(segment: string)

Source from the content-addressed store, hash-verified

528}
529
530function 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.

Callers 1

decodePathFunction · 0.85

Calls 1

sanitizePathSegmentFunction · 0.85

Tested by

no test coverage detected