You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 957026d
Browse filesBrowse the repository at this point in the historyBrowse files
fix(pages): keep the named action key first when a redirect repeats the request (#533)
Follow-up to #530 (Codex finding on that PR, which got merged before
this fix landed).
## Problem
A redirect that sends the same request again keeps the action key
(307/308, or 301/302 after PUT/PATCH/DELETE). When the destination has
its own query, the merge put the key **after** the destination's params:
```
PUT /books?delete&page=2 → c.redirect('/books-v2?tab=details', 302)
→ /books-v2?tab=details&delete=&page=2 repeated PUT picks "tab" ✗
```
## Fix (only in the `c.redirect` wrapper)
| Destination | Result |
|---|---|
| `/books-v2?tab=details` (another page) |
`/books-v2?delete&tab=details&page=2` (key first, as sent) |
| `/books-v2?tab=1&delete=x` (sets the key too) |
`/books-v2?delete=x&tab=1&page=2` (its value wins, moves first) |
| `/books?archive` (same page, own first key) | `/books?archive=&page=2`
(that key picks the action) |
| `/books-v2?` (bare reset) | `/books-v2?delete` (rest dropped, key
kept) |
| `/books-v2` (no query) | `/books-v2?delete&page=2` (unchanged, byte
for byte) |
| `#fragment` | stays last |
Unchanged: GET follow-ups (key dropped), unmarked requests,
`mergeQueryIntoLocation`, redirect rules and platform dispatch.
Known limit: a redirect to a **different** page whose first query key is
one of that page's actions (`c.redirect('/other?archive', 307)`) still
puts the request's key first. The redirect code can't tell an action key
from a normal param on another page.
## Tests
`routing-runtime.test.ts`: 10 new rows in the named-action table (307
and PUT 302 with a destination query, a valued key, a fragment, a bare
`?`, the same key in the destination, a same-page action key). 9 fail on
main. The POST 302 row passes on main too: it checks the GET follow-up
stays unchanged. routing-runtime, pages-client, pages-compile and
compile tests: 205/205. Lint, format and typecheck are clean.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
0 commit comments