@@ -11,7 +11,7 @@ import {
1111} from '../utils/fixture.js'
1212import { generateRandomObjectID , startMockBlobStore } from '../utils/helpers.js'
1313import { LocalServer } from '../utils/local-server.js'
14- import { hasNodeMiddlewareSupport } from '../utils/next-version-helpers.mjs'
14+ import { hasNodeMiddlewareSupport , nextVersionSatisfies } from '../utils/next-version-helpers.mjs'
1515
1616beforeEach < FixtureTestContext > ( async ( ctx ) => {
1717 // set for each test a new deployID and siteID
@@ -693,6 +693,17 @@ for (const {
693693 expect ( bodyFr . requestUrlPathname ) . toBe ( '/fr/json' )
694694 expect ( bodyFr . nextUrlPathname ) . toBe ( '/json' )
695695 expect ( bodyFr . nextUrlLocale ) . toBe ( 'fr' )
696+
697+ const responseData = await invokeEdgeFunction ( ctx , {
698+ functions : [ edgeFunctionNameRoot ] ,
699+ origin,
700+ url : `/_next/data/build_id/en/dynamic/test.json?slug=test` ,
701+ } )
702+
703+ expect (
704+ responseData . headers . get ( 'x-next-url-pathname' ) ,
705+ 'nextUrl.pathname should not be normalized due to skipMiddlewareUrlNormalize' ,
706+ ) . toEqual ( '/_next/data/build_id/en/dynamic/test.json' )
696707 } )
697708 } )
698709
@@ -719,6 +730,37 @@ for (const {
719730 )
720731 } )
721732 } )
733+
734+ describe ( 'Proxy specific' , ( ) => {
735+ test . skipIf ( ! nextVersionSatisfies ( '>=16.0.0-alpha.0' ) ) < FixtureTestContext > (
736+ 'skipProxyUrlNormalize in proxy.ts is supported' ,
737+ async ( ctx ) => {
738+ await createFixture ( 'proxy-i18n-skip-normalize' , ctx )
739+ await runPlugin ( ctx )
740+ const origin = await LocalServer . run ( async ( req , res ) => {
741+ res . write (
742+ JSON . stringify ( {
743+ url : req . url ,
744+ headers : req . headers ,
745+ } ) ,
746+ )
747+ res . end ( )
748+ } )
749+ ctx . cleanup ?. push ( ( ) => origin . stop ( ) )
750+
751+ const responseData = await invokeEdgeFunction ( ctx , {
752+ functions : [ edgeFunctionNameRoot ] ,
753+ origin,
754+ url : `/_next/data/build_id/en/dynamic/test.json` ,
755+ } )
756+
757+ expect (
758+ responseData . headers . get ( 'x-next-url-pathname' ) ,
759+ 'nextUrl.pathname should not be normalized due to skipProxyUrlNormalize' ,
760+ ) . toEqual ( '/_next/data/build_id/en/dynamic/test.json' )
761+ } ,
762+ )
763+ } )
722764 }
723765 } )
724766}
0 commit comments