MCPcopy Create free account
hub / github.com/TanStack/router / encodePathLikeUrl

Function encodePathLikeUrl

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

Source from the content-addressed store, hash-verified

687 * encodePathLikeUrl('/path/already%20encoded') // '/path/already%20encoded' (preserved)
688 */
689export function encodePathLikeUrl(path: string): string {
690 // Encode whitespace and non-ASCII characters that browsers encode in URLs
691
692 // biome-ignore lint/suspicious/noControlCharactersInRegex: intentional ASCII range check
693 // eslint-disable-next-line no-control-regex
694 if (!/\s|[^\u0000-\u007F]/.test(path)) return path
695 // biome-ignore lint/suspicious/noControlCharactersInRegex: intentional ASCII range check
696 // eslint-disable-next-line no-control-regex
697 return path.replace(/\s|[^\u0000-\u007F]/gu, encodeURIComponent)
698}
699
700/**
701 * 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