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

Function compileDecodeCharMap

packages/router-core/src/path.ts:205–218  ·  view source on GitHub ↗
(
  pathParamsAllowedCharacters: ReadonlyArray<string>,
)

Source from the content-addressed store, hash-verified

203 * This should be called once at router initialization.
204 */
205export function compileDecodeCharMap(
206 pathParamsAllowedCharacters: ReadonlyArray<string>,
207) {
208 const charMap = new Map(
209 pathParamsAllowedCharacters.map((char) => [encodeURIComponent(char), char]),
210 )
211 // Escape special regex characters and join with |
212 const pattern = Array.from(charMap.keys())
213 .map((key) => key.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'))
214 .join('|')
215 const regex = new RegExp(pattern, 'g')
216 return (encoded: string) =>
217 encoded.replace(regex, (match) => charMap.get(match) ?? match)
218}
219
220interface InterpolatePathOptions {
221 path?: string

Callers 2

RouterCoreClass · 0.90
path.test.tsFile · 0.90

Calls 2

replaceMethod · 0.65
getMethod · 0.65

Tested by

no test coverage detected