| 78 | } |
| 79 | |
| 80 | async function runCatchAllLoader(path: string): Promise<Response> { |
| 81 | const matched = matchRoutes(routes, path); |
| 82 | const leafRoute = matched?.at(-1)?.route; |
| 83 | if (typeof leafRoute?.loader !== "function") { |
| 84 | throw new Error(`No loader matched ${path}`); |
| 85 | } |
| 86 | const url = new URL(`https://app.example.com${path}`); |
| 87 | return leafRoute.loader({ |
| 88 | request: new Request(url), |
| 89 | url, |
| 90 | pattern: "*", |
| 91 | params: {}, |
| 92 | context: {}, |
| 93 | }) as Response | Promise<Response>; |
| 94 | } |
| 95 | |
| 96 | describe("rootGuard", () => { |
| 97 | test("error page is allowed directly", () => { |