(rawParams: string, codec: HttpParameterCodec)
| 76 | } |
| 77 | |
| 78 | function 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. |
no test coverage detected
searching dependent graphs…