MCPcopy Create free account
hub / github.com/Snapchat/Valdi / decodeQueryParams

Function decodeQueryParams

src/valdi_modules/src/valdi/coreutils/src/url.ts:19–28  ·  view source on GitHub ↗
(paramString: string)

Source from the content-addressed store, hash-verified

17 * Retrieve a map of from a querystring formatted string
18 */
19export function decodeQueryParams(paramString: string): DecodedParams {
20 return paramString
21 .split('&')
22 .filter(pair => pair) // remove empty strings
23 .map(pair => pair.split('=').map(decodeURIComponent))
24 .reduce((acc: DecodedParams, pairParts: string[]) => {
25 acc[pairParts[0]] = pairParts.length > 1 ? pairParts[1] : undefined;
26 return acc;
27 }, {});
28}
29
30/**
31 * Generate a path string with query params.

Callers 1

paramsFromUrlFunction · 0.85

Calls 4

filterMethod · 0.80
splitMethod · 0.80
reduceMethod · 0.45
mapMethod · 0.45

Tested by

no test coverage detected