diff --git a/packages/common/http/src/params.ts b/packages/common/http/src/params.ts index 60a71ef2d0..4298b6d49e 100755 --- a/packages/common/http/src/params.ts +++ b/packages/common/http/src/params.ts @@ -227,7 +227,7 @@ export class HttpParams { } } }); - this.cloneFrom = null; + this.cloneFrom = this.updates = null; } } } diff --git a/packages/common/http/test/params_spec.ts b/packages/common/http/test/params_spec.ts index 0e798129bd..669959c851 100644 --- a/packages/common/http/test/params_spec.ts +++ b/packages/common/http/test/params_spec.ts @@ -53,6 +53,15 @@ import {HttpParams} from '@angular/common/http/src/params'; const mutated = body.delete('a', '2').delete('a', '4'); expect(mutated.getAll('a')).toEqual(['1', '3', '5']); }); + + it('should not repeat mutations that have already been materialized', () => { + const body = new HttpParams({fromString: 'a=b'}); + const mutated = body.append('a', 'c'); + expect(mutated.toString()).toEqual('a=b&a=c'); + const mutated2 = mutated.append('c', 'd'); + expect(mutated.toString()).toEqual('a=b&a=c'); + expect(mutated2.toString()).toEqual('a=b&a=c&c=d'); + }); }); describe('read operations', () => {