* Serializes the body to an encoded string, where key-value pairs (separated by `=`) are * separated by `&`s.
()
| 278 | * separated by `&`s. |
| 279 | */ |
| 280 | toString(): string { |
| 281 | this.init(); |
| 282 | return ( |
| 283 | this.keys() |
| 284 | .map((key) => { |
| 285 | const eKey = this.encoder.encodeKey(key); |
| 286 | // `a: ['1']` produces `'a=1'` |
| 287 | // `b: []` produces `''` |
| 288 | // `c: ['1', '2']` produces `'c=1&c=2'` |
| 289 | return this.map!.get(key)! |
| 290 | .map((value) => eKey + '=' + this.encoder.encodeValue(value)) |
| 291 | .join('&'); |
| 292 | }) |
| 293 | // filter out empty values because `b: []` produces `''` |
| 294 | // which results in `a=1&&c=1&c=2` instead of `a=1&c=1&c=2` if we don't |
| 295 | .filter((param) => param !== '') |
| 296 | .join('&') |
| 297 | ); |
| 298 | } |
| 299 | |
| 300 | private clone(update: Update | Update[]): HttpParams { |
| 301 | const clone = new HttpParams({encoder: this.encoder} as HttpParamsOptions); |