File tree Expand file tree Collapse file tree
packages/tanstackstart-react Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -82,12 +82,13 @@ function normalizeTunnelRouteOptions(options: TunnelRouteOptions): NormalizedTun
8282 return { resolvedPath : resolveTunnelRoute ( path || true ) , allowedDsns } ;
8383}
8484
85+ // `routeTree.gen.ts` quote style follows `tsr.config.json#quoteStyle` (`single` | `double`),
86+ // so we check both forms for each route-identifying key.
87+ const ROUTE_CONFLICT_KEYS = [ 'fullPath' , 'path' , 'id' ] as const ;
88+
8589function hasRouteConflict ( source : string , resolvedTunnelRoute : string ) : boolean {
86- return (
87- source . includes ( `fullPath: '${ resolvedTunnelRoute } '` ) ||
88- source . includes ( `path: '${ resolvedTunnelRoute } '` ) ||
89- source . includes ( `id: '${ resolvedTunnelRoute } '` )
90- ) ;
90+ const literals = [ `'${ resolvedTunnelRoute } '` , `"${ resolvedTunnelRoute } "` ] ;
91+ return ROUTE_CONFLICT_KEYS . some ( key => literals . some ( literal => source . includes ( `${ key } : ${ literal } ` ) ) ) ;
9192}
9293
9394function injectAfterLastImport ( source : string , statement : string ) : string {
Original file line number Diff line number Diff line change @@ -97,6 +97,17 @@ describe('tunnelRoute vite plugin', () => {
9797 ) ;
9898 } ) ;
9999
100+ it ( 'fails on route conflict when routeTree.gen.ts uses double quotes (tsr quoteStyle: double)' , ( ) => {
101+ const doubleQuotedMonitorTree = ROUTE_TREE_SOURCE . replace ( "path: '/'" , 'path: "/monitor"' ) . replace (
102+ "id: '/'" ,
103+ 'id: "/monitor"' ,
104+ ) ;
105+
106+ expect ( ( ) => injectManagedTunnelRoute ( doubleQuotedMonitorTree , '/monitor' ) ) . toThrow (
107+ 'Cannot register managed tunnel route "/monitor" because an existing TanStack Start route already uses that path.' ,
108+ ) ;
109+ } ) ;
110+
100111 it ( 'loads a virtual managed tunnel route module for a static tunnel path' , async ( ) => {
101112 const plugin = makeTunnelRoutePlugin ( {
102113 allowedDsns : [ 'http://public@localhost:3031/1337' ] ,
You can’t perform that action at this time.
0 commit comments