MCPcopy Create free account
hub / github.com/ProNextJS/declarative-routing / convertURLSearchParamsToObject

Function convertURLSearchParamsToObject

assets/nextjs/hooks.ts:56–73  ·  view source on GitHub ↗
(
  params: Readonly<URLSearchParams> | null
)

Source from the content-addressed store, hash-verified

54}
55
56function convertURLSearchParamsToObject(
57 params: Readonly<URLSearchParams> | null
58): Record<string, string | string[]> {
59 if (!params) {
60 return {};
61 }
62
63 const obj: Record<string, string | string[]> = {};
64 // @ts-ignore
65 for (const [key, value] of params.entries()) {
66 if (params.getAll(key).length > 1) {
67 obj[key] = params.getAll(key);
68 } else {
69 obj[key] = value;
70 }
71 }
72 return obj;
73}

Callers 1

useSearchParamsFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected