@@ -8,7 +8,7 @@ describe('get-page-static-infos', () => {
88 {
99 originalSource : '/middleware/path' ,
1010 regexp :
11- '^(?:\\/(_next\\/data\\/[^/]{1,}))?\\/middleware\\/path(\\.json)?[\\/#\\?]?$' ,
11+ '^(?:\\/(_next\\/data\\/[^/]{1,}))?\\/middleware\\/path(\\.json|\\.rsc|\\.segments\\/.+\\.segment\\.rsc )?[\\/#\\?]?$' ,
1212 } ,
1313 ]
1414 const result = getMiddlewareMatchers ( matchers , { i18n : undefined } )
@@ -21,25 +21,70 @@ describe('get-page-static-infos', () => {
2121 {
2222 originalSource : '/middleware/path' ,
2323 regexp :
24- '^(?:\\/(_next\\/data\\/[^/]{1,}))?\\/middleware\\/path(\\.json)?[\\/#\\?]?$' ,
24+ '^(?:\\/(_next\\/data\\/[^/]{1,}))?\\/middleware\\/path(\\.json|\\.rsc|\\.segments\\/.+\\.segment\\.rsc )?[\\/#\\?]?$' ,
2525 } ,
2626 {
2727 originalSource : '/middleware/another-path' ,
2828 regexp :
29- '^(?:\\/(_next\\/data\\/[^/]{1,}))?\\/middleware\\/another-path(\\.json)?[\\/#\\?]?$' ,
29+ '^(?:\\/(_next\\/data\\/[^/]{1,}))?\\/middleware\\/another-path(\\.json|\\.rsc|\\.segments\\/.+\\.segment\\.rsc )?[\\/#\\?]?$' ,
3030 } ,
3131 ]
3232 const result = getMiddlewareMatchers ( matchers , { i18n : undefined } )
3333 expect ( result ) . toStrictEqual ( expected )
3434 } )
3535
36- it ( 'matches /:id and /:id.json ' , ( ) => {
36+ it ( 'matches /:id and transport variants for the same route ' , ( ) => {
3737 const matchers = [ '/:id' ]
3838 const result = getMiddlewareMatchers ( matchers , { i18n : undefined } ) [ 0 ]
3939 . regexp
4040 const regex = new RegExp ( result )
4141 expect ( regex . test ( '/apple' ) ) . toBe ( true )
4242 expect ( regex . test ( '/apple.json' ) ) . toBe ( true )
43+ expect ( regex . test ( '/apple.rsc' ) ) . toBe ( true )
44+ } )
45+
46+ it ( 'matches App Router segment-prefetch routes for static matchers' , ( ) => {
47+ const regex = new RegExp (
48+ getMiddlewareMatchers ( '/dashboard' , { i18n : undefined } ) [ 0 ] . regexp
49+ )
50+
51+ expect ( regex . test ( '/dashboard.rsc' ) ) . toBe ( true )
52+ expect (
53+ regex . test ( '/dashboard.segments/$c$children/__PAGE__.segment.rsc' )
54+ ) . toBe ( true )
55+ expect (
56+ regex . test ( '/settings.segments/$c$children/__PAGE__.segment.rsc' )
57+ ) . toBe ( false )
58+ } )
59+
60+ it ( 'matches App Router segment-prefetch routes for nested matchers' , ( ) => {
61+ const regex = new RegExp (
62+ getMiddlewareMatchers ( '/dashboard/:path*' , {
63+ i18n : undefined ,
64+ } ) [ 0 ] . regexp
65+ )
66+
67+ expect (
68+ regex . test (
69+ '/dashboard/settings.segments/$c$children/__PAGE__.segment.rsc'
70+ )
71+ ) . toBe ( true )
72+ expect (
73+ regex . test (
74+ '/marketing/settings.segments/$c$children/__PAGE__.segment.rsc'
75+ )
76+ ) . toBe ( false )
77+ } )
78+
79+ it ( 'matches the root App Router segment-prefetch transport route' , ( ) => {
80+ const regex = new RegExp (
81+ getMiddlewareMatchers ( '/' , { i18n : undefined } ) [ 0 ] . regexp
82+ )
83+
84+ expect ( regex . test ( '/index.rsc' ) ) . toBe ( true )
85+ expect (
86+ regex . test ( '/index.segments/$c$children/__PAGE__.segment.rsc' )
87+ ) . toBe ( true )
4388 } )
4489 } )
4590} )
0 commit comments