@@ -1238,3 +1238,53 @@ describe('router.navigate navigation using optional path parameters - edge cases
12381238 expect ( router . state . location . pathname ) . toBe ( '/files/prefix.txt' )
12391239 } )
12401240} )
1241+
1242+ describe ( 'splat routes with empty splat' , ( ) => {
1243+ it . each ( [ { trailingSlash : true } , { trailingSlash : false } ] ) (
1244+ 'should handle empty _splat parameter with trailingSlash: $trailingSlash' ,
1245+ async ( { trailingSlash } ) => {
1246+ const tail = trailingSlash ? '/' : ''
1247+
1248+ const history = createMemoryHistory ( { initialEntries : [ '/' ] } )
1249+
1250+ const rootRoute = createRootRoute ( )
1251+ const indexRoute = createRoute ( {
1252+ getParentRoute : ( ) => rootRoute ,
1253+ path : '/' ,
1254+ } )
1255+
1256+ const splatRoute = createRoute ( {
1257+ getParentRoute : ( ) => rootRoute ,
1258+ path : 'splat/$' ,
1259+ } )
1260+
1261+ const router = createRouter ( {
1262+ routeTree : rootRoute . addChildren ( [ indexRoute , splatRoute ] ) ,
1263+ history,
1264+ trailingSlash : trailingSlash ? 'always' : 'never' ,
1265+ } )
1266+
1267+ await router . load ( )
1268+
1269+ // All of these route params should navigate to the same location
1270+ const paramSets = [ {
1271+ _splat : ''
1272+ } , {
1273+ _splat : undefined
1274+ } , { } ]
1275+
1276+ for ( const params of paramSets ) {
1277+ await router . navigate ( {
1278+ to : '/splat/$' ,
1279+ params,
1280+ } )
1281+ await router . invalidate ( )
1282+
1283+ expect ( router . state . location . pathname ) . toBe ( `/splat${ tail } ` )
1284+ // Navigate back to index
1285+ await router . navigate ( { to : '/' } )
1286+ await router . invalidate ( )
1287+ }
1288+ } ,
1289+ )
1290+ } )
0 commit comments