fix(UrlParser): stop setting default value 'true' (#10399)

This commit is contained in:
Suguru Inatomi 2016-07-31 06:34:03 +09:00 committed by Rob Wormald
parent c8989c900f
commit 0d6cc17252
2 changed files with 13 additions and 3 deletions

View File

@ -406,7 +406,7 @@ class UrlParser {
return; return;
} }
this.capture(key); this.capture(key);
let value: any = 'true'; let value: any = '';
if (this.peekStartsWith('=')) { if (this.peekStartsWith('=')) {
this.capture('='); this.capture('=');
var valueMatch = matchUrlQueryParamValue(this.remaining); var valueMatch = matchUrlQueryParamValue(this.remaining);

View File

@ -142,12 +142,22 @@ describe('url serializer', () => {
it('should parse key only query params', () => { it('should parse key only query params', () => {
const tree = url.parse('/one?a'); 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', () => { it('should serializer query params', () => {
const tree = url.parse('/one?a'); 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', () => { it('should parse fragment', () => {