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

Function encodePathLikeUrl

packages/router-core/src/utils.ts:670–679  ·  view source on GitHub ↗
(path: string)

Source from the content-addressed store, hash-verified

668 * encodePathLikeUrl('/path/already%20encoded') // '/path/already%20encoded' (preserved)
669 */
670export function encodePathLikeUrl(path: string): string {
671 // Encode whitespace and non-ASCII characters that browsers encode in URLs
672
673 // biome-ignore lint/suspicious/noControlCharactersInRegex: intentional ASCII range check
674 // eslint-disable-next-line no-control-regex
675 if (!/\s|[^\u0000-\u007F]/.test(path)) return path
676 // biome-ignore lint/suspicious/noControlCharactersInRegex: intentional ASCII range check
677 // eslint-disable-next-line no-control-regex
678 return path.replace(/\s|[^\u0000-\u007F]/gu, encodeURIComponent)
679}
680
681/**
682 * Builds the dev-mode CSS styles URL for route-scoped CSS collection.

Callers 2

buildMethod · 0.90
utils.test.tsFile · 0.90

Calls 1

replaceMethod · 0.65

Tested by

no test coverage detected