Repository navigation
Commit bf20661
fix(pages): report the requested URL in page data after a rewrite (#799)
Closes #798
## Problem
A rewrite (`c.rewrite()`, `routing.rewrites`, `routing.fallbacks`,
`_redirects` `200`) serves another route without changing the browser
URL. But the page data's `url` was built from the rewritten request, so
the client router took the destination as the current URL. After a
rewrite, `useRouter().url`, `.path` and `.query` described the
destination, `router.refresh()` loaded the destination, and active-link
matching treated the visitor as being on it.
## Change
`requestPathWithSearch()` in `packages/void/src/pages/protocol.ts` now
builds the URL from `c.originalUrl()` when the request was rewritten:
- The path goes through `decodePagePath()`, so it is decoded the same
way `c.req.path` is (`/caf%C3%A9` → `/café`). Requests that were not
rewritten get the same URL as before.
- The action re-render branch uses the same helper and still leaves out
the action key.
- Build-time renders (`createStaticNotFound`) run without the routing
context middleware, so the helper falls back to the served request when
`c.originalUrl` is absent.
The client already keeps the requested URL in history after a mutation
rewrite (3c53034). One assertion in `pages-client.test.ts` checked
that the server sent the destination URL; it now expects the visible
URL.
## Tests
- New `routing-runtime.test.ts` cases cover middleware and rule rewrites
for GET page loads, an encoded path, and named-action re-renders. All
five fail without the fix (`/maintenance?tab=1` instead of
`/app/account?tab=1`).
- `vp run check`, `vp lint` and `vp fmt --check` pass.
- `vp test run`: 792 test files passed, 1 skipped.
No docs change: the rewrites reference already says the browser URL does
not change.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>1 parent bf08a6e commit bf20661
3 files changed
Lines changed: 64 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
| |||
299 | 300 | | |
300 | 301 | | |
301 | 302 | | |
302 | | - | |
303 | | - | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
304 | 322 | | |
305 | 323 | | |
306 | 324 | | |
| |||
908 | 926 | | |
909 | 927 | | |
910 | 928 | | |
911 | | - | |
912 | | - | |
913 | | - | |
| 929 | + | |
914 | 930 | | |
915 | 931 | | |
916 | 932 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1439 | 1439 | | |
1440 | 1440 | | |
1441 | 1441 | | |
1442 | | - | |
| 1442 | + | |
1443 | 1443 | | |
1444 | 1444 | | |
1445 | 1445 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1166 | 1166 | | |
1167 | 1167 | | |
1168 | 1168 | | |
| 1169 | + | |
| 1170 | + | |
| 1171 | + | |
| 1172 | + | |
| 1173 | + | |
| 1174 | + | |
| 1175 | + | |
| 1176 | + | |
| 1177 | + | |
| 1178 | + | |
| 1179 | + | |
| 1180 | + | |
| 1181 | + | |
| 1182 | + | |
| 1183 | + | |
| 1184 | + | |
| 1185 | + | |
| 1186 | + | |
| 1187 | + | |
| 1188 | + | |
| 1189 | + | |
| 1190 | + | |
| 1191 | + | |
| 1192 | + | |
| 1193 | + | |
| 1194 | + | |
| 1195 | + | |
| 1196 | + | |
| 1197 | + | |
| 1198 | + | |
| 1199 | + | |
| 1200 | + | |
| 1201 | + | |
| 1202 | + | |
| 1203 | + | |
| 1204 | + | |
| 1205 | + | |
| 1206 | + | |
| 1207 | + | |
| 1208 | + | |
| 1209 | + | |
| 1210 | + | |
1169 | 1211 | | |
1170 | 1212 | | |
1171 | 1213 | | |
| |||
0 commit comments