fix(router): fix query param parsing
This commit is contained in:
parent
0ab04bd62c
commit
a487563768
|
@ -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] : '';
|
||||
}
|
||||
|
||||
|
|
|
@ -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', () => {
|
||||
|
|
Loading…
Reference in New Issue