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

Function getParamValueFromCacheKey

packages/next/src/client/route-params.ts:216–233  ·  view source on GitHub ↗
(
  paramCacheKey: string,
  paramType: DynamicParamTypesShort
)

Source from the content-addressed store, hash-verified

214}
215
216export function getParamValueFromCacheKey(
217 paramCacheKey: string,
218 paramType: DynamicParamTypesShort
219) {
220 // Turn the cache key string sent by the server (as part of FlightRouterState)
221 // into a value that can be passed to `useParams` and client components.
222 const isCatchAll = paramType === 'c' || paramType === 'oc'
223 if (isCatchAll) {
224 // Catch-all param keys are a concatenation of the path segments.
225 // See equivalent logic in `getSelectedParams`.
226 // TODO: We should just pass the array directly, rather than concatenate
227 // it to a string and then split it back to an array. It needs to be an
228 // array in some places, like when passing a key React, but we can convert
229 // it at runtime in those places.
230 return paramCacheKey.split('/')
231 }
232 return paramCacheKey
233}
234
235export function urlSearchParamsToParsedUrlQuery(
236 searchParams: URLSearchParams

Callers 1

OuterLayoutRouterFunction · 0.90

Calls 1

splitMethod · 0.80

Tested by

no test coverage detected