| 866 | describe('createUrlTree with custom serializer', () => { |
| 867 | class CustomUrlSerializer extends DefaultUrlSerializer { |
| 868 | override parse(url: string): UrlTree { |
| 869 | const tree = super.parse(url); |
| 870 | const qp: {[key: string]: any} = {}; |
| 871 | Object.keys(tree.queryParams).forEach((key) => { |
| 872 | const value = tree.queryParams[key]; |
| 873 | if (typeof value === 'string' && (value.startsWith('{') || value.startsWith('['))) { |
| 874 | try { |
| 875 | qp[key] = JSON.parse(value); |
| 876 | } catch {} |
| 877 | } else { |
| 878 | qp[key] = value; |
| 879 | } |
| 880 | }); |
| 881 | tree.queryParams = qp; |
| 882 | return tree; |
| 883 | } |
| 884 | override serialize(tree: UrlTree): string { |
| 885 | const qp: {[key: string]: any} = {}; |
| 886 | Object.keys(tree.queryParams).forEach((key) => { |