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

Function composeRewrites

packages/router-core/src/rewrite.ts:6–21  ·  view source on GitHub ↗
(rewrites: Array<LocationRewrite>)

Source from the content-addressed store, hash-verified

4/** Compose multiple rewrite pairs into a single in/out rewrite. */
5/** Compose multiple rewrite pairs into a single in/out rewrite. */
6export function composeRewrites(rewrites: Array<LocationRewrite>) {
7 return {
8 input: ({ url }) => {
9 for (const rewrite of rewrites) {
10 url = executeRewriteInput(rewrite, url)
11 }
12 return url
13 },
14 output: ({ url }) => {
15 for (let i = rewrites.length - 1; i >= 0; i--) {
16 url = executeRewriteOutput(rewrites[i], url)
17 }
18 return url
19 },
20 } satisfies LocationRewrite
21}
22
23/** Create a rewrite pair that strips/adds a basepath on input/output. */
24/** Create a rewrite pair that strips/adds a basepath on input/output. */

Callers 4

RouterCoreClass · 0.90
router.test.tsxFile · 0.90
router.test.tsxFile · 0.90
router.test.tsxFile · 0.90

Calls 2

executeRewriteInputFunction · 0.85
executeRewriteOutputFunction · 0.85

Tested by

no test coverage detected