diff --git a/modules/@angular/router/src/url_tree.ts b/modules/@angular/router/src/url_tree.ts index 55b950ab9a..2e6350cb80 100644 --- a/modules/@angular/router/src/url_tree.ts +++ b/modules/@angular/router/src/url_tree.ts @@ -406,7 +406,7 @@ class UrlParser { return; } this.capture(key); - let value: any = 'true'; + let value: any = ''; if (this.peekStartsWith('=')) { this.capture('='); var valueMatch = matchUrlQueryParamValue(this.remaining); diff --git a/modules/@angular/router/test/url_serializer.spec.ts b/modules/@angular/router/test/url_serializer.spec.ts index a8081311ae..65a0def53c 100644 --- a/modules/@angular/router/test/url_serializer.spec.ts +++ b/modules/@angular/router/test/url_serializer.spec.ts @@ -142,12 +142,22 @@ describe('url serializer', () => { it('should parse key only query params', () => { const tree = url.parse('/one?a'); - expect(tree.queryParams).toEqual({a: 'true'}); + expect(tree.queryParams).toEqual({a: ''}); + }); + + it('should parse a value-empty query param', () => { + const tree = url.parse('/one?a='); + expect(tree.queryParams).toEqual({a: ''}); + }); + + it('should parse value-empty query params', () => { + const tree = url.parse('/one?a=&b='); + expect(tree.queryParams).toEqual({a: '', b: ''}); }); it('should serializer query params', () => { const tree = url.parse('/one?a'); - expect(url.serialize(tree)).toEqual('/one?a=true'); + expect(url.serialize(tree)).toEqual('/one?a='); }); it('should parse fragment', () => {