(paramString: string)
| 17 | * Retrieve a map of from a querystring formatted string |
| 18 | */ |
| 19 | export 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. |
no test coverage detected