MCPcopy Index your code
hub / github.com/angular/angular / paramParser

Function paramParser

packages/common/http/src/params.ts:78–97  ·  view source on GitHub ↗
(rawParams: string, codec: HttpParameterCodec)

Source from the content-addressed store, hash-verified

76}
77
78function paramParser(rawParams: string, codec: HttpParameterCodec): Map<string, string[]> {
79 const map = new Map<string, string[]>();
80 if (rawParams.length > 0) {
81 // The `window.location.search` can be used while creating an instance of the `HttpParams` class
82 // (e.g. `new HttpParams({ fromString: window.location.search })`). The `window.location.search`
83 // may start with the `?` char, so we strip it if it's present.
84 const params: string[] = rawParams.replace(/^\?/, '').split('&');
85 params.forEach((param: string) => {
86 const eqIdx = param.indexOf('=');
87 const [key, val]: string[] =
88 eqIdx == -1
89 ? [codec.decodeKey(param), '']
90 : [codec.decodeKey(param.slice(0, eqIdx)), codec.decodeValue(param.slice(eqIdx + 1))];
91 const list = map.get(key) || [];
92 list.push(val);
93 map.set(key, list);
94 });
95 }
96 return map;
97}
98
99/**
100 * Encode input string with standard encodeURIComponent and then un-encode specific characters.

Callers 1

constructorMethod · 0.85

Calls 8

indexOfMethod · 0.80
decodeKeyMethod · 0.65
decodeValueMethod · 0.65
getMethod · 0.65
setMethod · 0.65
replaceMethod · 0.45
forEachMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…