| 768 | describe('createUrlTree with custom serializer', () => { |
| 769 | class CustomUrlSerializer extends DefaultUrlSerializer { |
| 770 | override parse(url: string): UrlTree { |
| 771 | const tree = super.parse(url); |
| 772 | const qp: {[key: string]: any} = {}; |
| 773 | Object.keys(tree.queryParams).forEach((key) => { |
| 774 | const value = tree.queryParams[key]; |
| 775 | if (typeof value === 'string' && (value.startsWith('{') || value.startsWith('['))) { |
| 776 | try { |
| 777 | qp[key] = JSON.parse(value); |
| 778 | } catch {} |
| 779 | } else { |
| 780 | qp[key] = value; |
| 781 | } |
| 782 | }); |
| 783 | tree.queryParams = qp; |
| 784 | return tree; |
| 785 | } |
| 786 | override serialize(tree: UrlTree): string { |
| 787 | const qp: {[key: string]: any} = {}; |
| 788 | Object.keys(tree.queryParams).forEach((key) => { |