MCPcopy
hub / github.com/vercel/next.js / normalizeQueryParams

Function normalizeQueryParams

packages/next/src/server/server-utils.ts:425–448  ·  view source on GitHub ↗
(
    query: Record<string, string | string[] | undefined>,
    routeParamKeys: Set<string>
  )

Source from the content-addressed store, hash-verified

423 }
424
425 function normalizeQueryParams(
426 query: Record<string, string | string[] | undefined>,
427 routeParamKeys: Set<string>
428 ) {
429 // this is used to pass query information in rewrites
430 // but should not be exposed in final query
431 delete query['nextInternalLocale']
432
433 for (const [key, value] of Object.entries(query)) {
434 const normalizedKey = normalizeNextQueryParam(key)
435 if (!normalizedKey) continue
436
437 // Remove the prefixed key from the query params because we want
438 // to consume it for the dynamic route matcher.
439 delete query[key]
440 routeParamKeys.add(normalizedKey)
441
442 if (typeof value === 'undefined') continue
443
444 query[normalizedKey] = Array.isArray(value)
445 ? value.map((v) => decodeQueryPathParameter(v))
446 : decodeQueryPathParameter(value)
447 }
448 }
449
450 return {
451 handleRewrites,

Callers

nothing calls this directly

Calls 6

normalizeNextQueryParamFunction · 0.90
decodeQueryPathParameterFunction · 0.90
isArrayMethod · 0.80
entriesMethod · 0.45
addMethod · 0.45
mapMethod · 0.45

Tested by

no test coverage detected