| 826 | describe('createUrlTree with custom serializer', () => { |
| 827 | class CustomUrlSerializer extends DefaultUrlSerializer { |
| 828 | override parse(url: string): UrlTree { |
| 829 | const tree = super.parse(url); |
| 830 | const qp: {[key: string]: any} = {}; |
| 831 | Object.keys(tree.queryParams).forEach((key) => { |
| 832 | const value = tree.queryParams[key]; |
| 833 | if (typeof value === 'string' && (value.startsWith('{') || value.startsWith('['))) { |
| 834 | try { |
| 835 | qp[key] = JSON.parse(value); |
| 836 | } catch {} |
| 837 | } else { |
| 838 | qp[key] = value; |
| 839 | } |
| 840 | }); |
| 841 | tree.queryParams = qp; |
| 842 | return tree; |
| 843 | } |
| 844 | override serialize(tree: UrlTree): string { |
| 845 | const qp: {[key: string]: any} = {}; |
| 846 | Object.keys(tree.queryParams).forEach((key) => { |