MCPcopy Create free account
hub / github.com/angular/angular / toString

Method toString

packages/common/http/src/params.ts:280–298  ·  view source on GitHub ↗

* Serializes the body to an encoded string, where key-value pairs (separated by `=`) are * separated by `&`s.

()

Source from the content-addressed store, hash-verified

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);

Callers

nothing calls this directly

Calls 8

initMethod · 0.95
keysMethod · 0.95
mapMethod · 0.80
joinMethod · 0.65
encodeKeyMethod · 0.65
getMethod · 0.65
encodeValueMethod · 0.65
filterMethod · 0.45

Tested by

no test coverage detected