(rewrites: Array<LocationRewrite>)
| 4 | /** Compose multiple rewrite pairs into a single in/out rewrite. */ |
| 5 | /** Compose multiple rewrite pairs into a single in/out rewrite. */ |
| 6 | export 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. */ |
no test coverage detected