@@ -88,6 +88,47 @@ describe("Utils - RouterParserUtil", () => {
8888 ) . to . equal ( '[{path:"USER/CREATE"}]' ) ;
8989 } ) ;
9090
91+ it ( "should keep a plain route string with multiple params JSON5-parseable (issue #1302)" , ( ) => {
92+ const cleaned = routerParser . cleanRawRoute (
93+ '[{path:"sample/:sample/example/:example"}]' ,
94+ ) ;
95+ let parsed : any ;
96+ expect ( ( ) => {
97+ parsed = require ( "json5" ) . parse ( cleaned ) ;
98+ } ) . not . to . throw ( ) ;
99+ expect ( parsed [ 0 ] . path ) . to . equal ( "sample/:sample/example/:example" ) ;
100+ } ) ;
101+
102+ it ( "should keep a template-literal route with multiple params JSON5-parseable (issue #1302)" , ( ) => {
103+ const project = new Project ( { useInMemoryFileSystem : true } ) ;
104+ const sourceFile = project . createSourceFile (
105+ "/tmp/routes-1302.ts" ,
106+ `
107+ import { Routes } from "@angular/router";
108+ const sample = "sample";
109+ const example = "example";
110+ const routes: Routes = [
111+ { path: \`sample/:\${sample}/example/:\${example}\` }
112+ ];
113+ ` ,
114+ ) ;
115+
116+ routerParser . cleanFileDynamics ( sourceFile ) ;
117+ routerParser . cleanCallExpressions ( sourceFile ) ;
118+
119+ const initializer = sourceFile
120+ . getVariableDeclarationOrThrow ( "routes" )
121+ . getInitializerOrThrow ( ) . compilerNode ;
122+ const generated = new CodeGenerator ( ) . generate ( initializer ) ;
123+ const cleaned = routerParser . cleanRawRoute ( generated ) ;
124+
125+ let parsed : any ;
126+ expect ( ( ) => {
127+ parsed = require ( "json5" ) . parse ( cleaned ) ;
128+ } ) . not . to . throw ( ) ;
129+ expect ( parsed [ 0 ] . path ) . to . equal ( "sample/:sample/example/:example" ) ;
130+ } ) ;
131+
91132 // ── Standalone property-access chains — normalized for safe parsing ──
92133
93134 it ( "should quote a standalone property-access chain to keep JSON5 parseable" , ( ) => {
0 commit comments