diff --git a/packages/router/src/url_tree.ts b/packages/router/src/url_tree.ts index cd7d1b131e..13841a2789 100644 --- a/packages/router/src/url_tree.ts +++ b/packages/router/src/url_tree.ts @@ -523,7 +523,7 @@ function matchQueryParams(str: string): string { return match ? match[0] : ''; } -const QUERY_PARAM_VALUE_RE = /^[^?&#]+/; +const QUERY_PARAM_VALUE_RE = /^[^&#]+/; // Return the value of the query param at the start of the string or an empty string function matchUrlQueryParamValue(str: string): string { const match = str.match(QUERY_PARAM_VALUE_RE); diff --git a/packages/router/test/url_tree.spec.ts b/packages/router/test/url_tree.spec.ts index 8adc90c2d7..4ccbffe99c 100644 --- a/packages/router/test/url_tree.spec.ts +++ b/packages/router/test/url_tree.spec.ts @@ -26,6 +26,11 @@ describe('UrlTree', () => { 'k/(a;b)': 'c', }); }); + + it('should allow question marks in query param values', () => { + const tree = serializer.parse('/path/to?first=http://foo/bar?baz=true&second=123'); + expect(tree.queryParams).toEqual({'first': 'http://foo/bar?baz=true', 'second': '123'}); + }); }); describe('containsTree', () => {