Files
JosephandGitHub c3bf2a395a fix: preserve repeated search params in client page segment cache keys (#94863)
Fixes: #94821, #92787, #93104

Using `Object.fromEntries` on URLSearchParams, drops repeated keys.

```js
const s = '?foo=bar&foo=baz'
Object.fromEntries(new URLSearchParams(s)) // { foo: 'baz' }
```

There's already a function, `urlSearchParamsToParsedUrlQuery`, which
handles this case.


https://github.com/vercel/next.js/blob/40296fe53f40ffe6a0e2184879bd5e294d271ce4/packages/next/src/client/route-params.ts#L235

```js
urlSearchParamsToParsedUrlQuery(new URLSearchParams(s)) // { foo: ['bar', 'baz'] }
```

- [x] The e2e off one of the issue reports, I'll try to simplify it.
2026-06-29 13:54:29 +02:00

24 lines
582 B
TypeScript

import Link from 'next/link'
import { Suspense } from 'react'
export default function Page({ searchParams }: PageProps<'/'>) {
return (
<main>
<Link id="to-bar" href="/?foo=bar">
foo=bar
</Link>
<Link id="to-bar-baz" href="/?foo=bar&foo=baz">
foo=bar&foo=baz
</Link>
<Link id="to-baz" href="/?foo=baz">
foo=baz
</Link>
<Suspense fallback={null}>
{searchParams.then((params) => (
<pre id="search-params">{JSON.stringify(params, null, 2)}</pre>
))}
</Suspense>
</main>
)
}