MCPcopy Create free account
hub / github.com/vercel/vercel / parseQueryString

Function parseQueryString

packages/cli/src/util/dev/parse-query-string.ts:6–32  ·  view source on GitHub ↗
(
  querystring?: string | null
)

Source from the content-addressed store, hash-verified

4 * @param querystring - The querystring to parse, also known as the "search" string.
5 */
6export function parseQueryString(
7 querystring?: string | null
8): Record<string, string[]> {
9 const query: Record<string, string[]> = Object.create(null);
10 if (!querystring || !querystring.startsWith('?') || querystring === '?') {
11 return query;
12 }
13 const params = querystring.slice(1).split('&');
14 for (const param of params) {
15 let [key, value] = param.split('=');
16 if (key !== undefined) {
17 key = decodeURIComponent(key);
18 }
19 if (value !== undefined) {
20 value = decodeURIComponent(value);
21 }
22
23 let existing = query[key];
24 if (!existing) {
25 existing = [];
26 query[key] = existing;
27 }
28
29 existing.push(value);
30 }
31 return query;
32}
33
34/**
35 * This function is necessary to account for the difference between

Callers 5

devRouterFunction · 0.90
applyRequestTransformsFunction · 0.90
getReqUrlMethod · 0.90
DevServerClass · 0.90

Calls 3

splitMethod · 0.80
pushMethod · 0.65
createMethod · 0.45

Tested by

no test coverage detected