Skip to content

Commit

Permalink
fix(router): fix query param parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
vicb authored and hansl committed Apr 11, 2017
1 parent 0ab04bd commit a487563
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/router/src/url_tree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ function matchSegments(str: string): string {
const QUERY_PARAM_RE = /^[^=?&#]+/;
// Return the name of the query param at the start of the string or an empty string
function matchQueryParams(str: string): string {
const match = str.match(SEGMENT_RE);
const match = str.match(QUERY_PARAM_RE);
return match ? match[0] : '';
}

Expand Down
14 changes: 14 additions & 0 deletions packages/router/test/url_tree.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,20 @@ import {DefaultUrlSerializer, containsTree} from '../src/url_tree';
describe('UrlTree', () => {
const serializer = new DefaultUrlSerializer();

describe('DefaultUrlSerializer', () => {
let serializer: DefaultUrlSerializer;

beforeEach(() => { serializer = new DefaultUrlSerializer(); });

it('should parse query parameters', () => {
const tree = serializer.parse('/path/to?k=v&k/(a;b)=c');
expect(tree.queryParams).toEqual({
'k': 'v',
'k/(a;b)': 'c',
});
});
});

describe('containsTree', () => {
describe('exact = true', () => {
it('should return true when two tree are the same', () => {
Expand Down

0 comments on commit a487563

Please sign in to comment.