File tree Expand file tree Collapse file tree 1 file changed +24
-6
lines changed
packages/tests-unit/tests/core/routing Expand file tree Collapse file tree 1 file changed +24
-6
lines changed Original file line number Diff line number Diff line change @@ -240,13 +240,31 @@ describe("handleRedirects", () => {
240240 {
241241 source : "/:path+" ,
242242 destination : "/new/:path+" ,
243- internal : true ,
243+ locale : false ,
244244 statusCode : 308 ,
245- regex : "^(?:/((?:[^/]+?)(?:/(?:[^/]+?))*))/ $" ,
245+ regex : "^(?!/_next)(? :/((?:[^/]+?)(?:/(?:[^/]+?))*))(?:/)? $" ,
246246 } ,
247247 ] ) ;
248248
249- expect ( result ) . toBeUndefined ( ) ;
249+ expect ( result . headers . Location ) . toBe ( "/new/api-route" ) ;
250+ } ) ;
251+
252+ it ( "should redirect matching nested path" , ( ) => {
253+ const event = createEvent ( {
254+ url : "/api-route/secret" ,
255+ } ) ;
256+
257+ const result = handleRedirects ( event , [
258+ {
259+ source : "/:path+" ,
260+ destination : "/new/:path+" ,
261+ locale : false ,
262+ statusCode : 308 ,
263+ regex : "^(?!/_next)(?:/((?:[^/]+?)(?:/(?:[^/]+?))*))(?:/)?$" ,
264+ } ,
265+ ] ) ;
266+
267+ expect ( result . headers . Location ) . toBe ( "/new/api-route/secret" ) ;
250268 } ) ;
251269
252270 it ( "should not redirect unmatched path" , ( ) => {
@@ -258,9 +276,9 @@ describe("handleRedirects", () => {
258276 {
259277 source : "/foo/" ,
260278 destination : "/bar" ,
261- internal : true ,
262- statusCode : 308 ,
263- regex : "^(?:/((?:[^/]+?)(?:/ (?:[^/]+?))*))/ $" ,
279+ locale : false ,
280+ statusCode : 307 ,
281+ regex : "^(?!/_next)/foo/ (?:/)? $" ,
264282 } ,
265283 ] ) ;
266284
You can’t perform that action at this time.
0 commit comments