fix(router): fix query param parsing

This commit is contained in:
Victor Berchet 2017-04-04 09:01:39 -07:00 committed by Hans
parent 0ab04bd62c
commit a487563768
2 changed files with 15 additions and 1 deletions

View File

@ -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] : '';
}

View File

@ -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', () => {