mirror of
https://github.com/cloudflare/vinext.git
synced 2026-05-09 08:25:34 +02:00
[PR #421] [MERGED] fix: preserve Pages Router query arrays and hash in asPath #559
Labels
No labels
enhancement
enhancement
good first issue
help wanted
nextjs-tracking
nextjs-tracking
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/vinext#559
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/cloudflare/vinext/pull/421
Author: @JaredStowell
Created: 3/10/2026
Status: ✅ Merged
Merged: 3/10/2026
Merged by: @james-elicx
Base:
main← Head:jstowell/fix-pages-router-query-arrays-and-aspath-hash📝 Commits (2)
8e8764dHandle array query paramse4b2c62Fix router query merge order📊 Changes
5 files changed (+273 additions, -13 deletions)
View changed files
📝
packages/vinext/src/shims/router.ts(+11 -8)📝
packages/vinext/src/utils/query.ts(+21 -5)📝
tests/api-handler.test.ts(+19 -0)📝
tests/e2e/pages-router/shallow-routing.spec.ts(+52 -0)📝
tests/shims.test.ts(+170 -0)📄 Description
Fix Pages Router state reconstruction in
next/routerso it matches Next.js behavior more closely:string[]values inrouter.queryinstead of flattening them withjoin(",")?tag=a&tag=b->{ tag: ["a", "b"] })router.asPathon the client (#hashis no longer dropped)Root cause
getPathnameAndQuery()inpackages/vinext/src/shims/router.tshad three corruption points:__NEXT_DATA__.querywere converted to comma-joined stringsasPathwas rebuilt frompathname + search, which always droppedwindow.location.hashChanges
packages/vinext/src/shims/router.tsaddQueryParam()helperwindow.location.hashin clientasPathtests/shims.test.tsasPathtests/e2e/pages-router/shallow-routing.spec.ts#hashTesting
pnpm exec oxfmt packages/vinext/src/shims/router.ts tests/shims.test.ts tests/e2e/pages-router/shallow-routing.spec.tspnpm test tests/shims.test.tsPLAYWRIGHT_PROJECT=pages-router pnpm exec playwright test tests/e2e/pages-router/shallow-routing.spec.tspnpm exec oxlint --deny-warnings packages/vinext/src/shims/router.ts tests/shims.test.ts tests/e2e/pages-router/shallow-routing.spec.tspnpm run typecheckNotes
This PR fixes the read-side corruption in Pages Router state reconstruction. It does not change object-form navigation serialization for
router.push({ query: ... }), which is a separate write-path concern.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.