Unverified Commit dad32998 authored by Jan Potoms's avatar Jan Potoms Committed by GitHub

Improve query conversion logic (#15236)

`URLSearchParams` has a `forEach` method. this should simplify and shorten the logic. Perhaps it will even phix https://github.com/vercel/next.js/issues/15232
parent f00ad581
...@@ -4,7 +4,7 @@ export function searchParamsToUrlQuery( ...@@ -4,7 +4,7 @@ export function searchParamsToUrlQuery(
searchParams: URLSearchParams searchParams: URLSearchParams
): ParsedUrlQuery { ): ParsedUrlQuery {
const query: ParsedUrlQuery = {} const query: ParsedUrlQuery = {}
Array.from(searchParams.entries()).forEach(([key, value]) => { searchParams.forEach((value, key) => {
if (typeof query[key] === 'undefined') { if (typeof query[key] === 'undefined') {
query[key] = value query[key] = value
} else if (Array.isArray(query[key])) { } else if (Array.isArray(query[key])) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment