@@ -546,6 +546,30 @@ describe('findRouteMatch', () => {
546546 expect ( res ?. route . id ) . toBe ( '/a/b/$' )
547547 expect ( res ?. params ) . toEqual ( { _splat : 'foo' , '*' : 'foo' } )
548548 } )
549+ describe ( 'edge-case #5969: trailing empty wildcard should match' , ( ) => {
550+ it ( 'basic' , ( ) => {
551+ const tree = makeTree ( [ '/a/$' ] )
552+ expect ( findRouteMatch ( '/a/' , tree ) ?. route . id ) . toBe ( '/a/$' )
553+ expect ( findRouteMatch ( '/a' , tree ) ?. route . id ) . toBe ( '/a/$' )
554+ } )
555+ it ( 'with layout route' , ( ) => {
556+ const tree = makeTree ( [ '/a' , '/a/$' ] )
557+ expect ( findRouteMatch ( '/a/' , tree ) ?. route . id ) . toBe ( '/a/$' )
558+ expect ( findRouteMatch ( '/a' , tree ) ?. route . id ) . toBe ( '/a/$' )
559+ } )
560+ it ( 'with index route (should not match)' , ( ) => {
561+ const tree = makeTree ( [ '/a/' , '/a/$' ] )
562+ expect ( findRouteMatch ( '/a/' , tree ) ?. route . id ) . toBe ( '/a/' )
563+ expect ( findRouteMatch ( '/a' , tree ) ?. route . id ) . toBe ( '/a/' )
564+ } )
565+ it ( 'edge-case: deeper index route through skipped optional segments (should not match)' , ( ) => {
566+ const tree = makeTree ( [ '/{-$foo}/{-$bar}/a/' , '/a/$' ] )
567+ expect ( findRouteMatch ( '/a/' , tree ) ?. route . id ) . toBe (
568+ '/{-$foo}/{-$bar}/a/' ,
569+ )
570+ expect ( findRouteMatch ( '/a' , tree ) ?. route . id ) . toBe ( '/{-$foo}/{-$bar}/a/' )
571+ } )
572+ } )
549573 } )
550574
551575 describe ( 'nested routes' , ( ) => {
0 commit comments