mirror of
https://github.com/hanzoai/next.js.git
synced 2026-10-30 14:46:38 +00:00
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.
24 lines
582 B
TypeScript
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>
|
|
)
|
|
}
|