( paramCacheKey: string, paramType: DynamicParamTypesShort )
| 214 | } |
| 215 | |
| 216 | export 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 | |
| 235 | export function urlSearchParamsToParsedUrlQuery( |
| 236 | searchParams: URLSearchParams |
no test coverage detected