fix(router): fix query param parsing
This commit is contained in:
@ -360,7 +360,7 @@ function matchSegments(str: string): string {
|
|||||||
const QUERY_PARAM_RE = /^[^=?&#]+/;
|
const QUERY_PARAM_RE = /^[^=?&#]+/;
|
||||||
// Return the name of the query param at the start of the string or an empty string
|
// Return the name of the query param at the start of the string or an empty string
|
||||||
function matchQueryParams(str: string): string {
|
function matchQueryParams(str: string): string {
|
||||||
const match = str.match(SEGMENT_RE);
|
const match = str.match(QUERY_PARAM_RE);
|
||||||
return match ? match[0] : '';
|
return match ? match[0] : '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,6 +11,20 @@ import {DefaultUrlSerializer, containsTree} from '../src/url_tree';
|
|||||||
describe('UrlTree', () => {
|
describe('UrlTree', () => {
|
||||||
const serializer = new DefaultUrlSerializer();
|
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('containsTree', () => {
|
||||||
describe('exact = true', () => {
|
describe('exact = true', () => {
|
||||||
it('should return true when two tree are the same', () => {
|
it('should return true when two tree are the same', () => {
|
||||||
|
Reference in New Issue
Block a user