@@ -727,8 +727,7 @@ export async function handleBuildComplete({
727727
728728 // need to add matching .rsc output
729729 if ( isAppPage ) {
730- const rscPathname =
731- ( output . pathname === '/' ? '/index' : output . pathname ) + '.rsc'
730+ const rscPathname = normalizePagePath ( output . pathname ) + '.rsc'
732731 outputs . appPages . push ( {
733732 ...output ,
734733 pathname : rscPathname ,
@@ -864,7 +863,7 @@ export async function handleBuildComplete({
864863 const dataPathname = path . posix . join (
865864 '/_next/data' ,
866865 buildId ,
867- page + '.json'
866+ normalizePagePath ( page ) + '.json'
868867 )
869868 outputs . pages . push ( {
870869 ...output ,
@@ -1002,9 +1001,8 @@ export async function handleBuildComplete({
10021001 if ( output . type === AdapterOutputType . APP_PAGE ) {
10031002 outputs . appPages . push ( {
10041003 ...output ,
1005- pathname :
1006- ( output . pathname === '/' ? '/index' : output . pathname ) + '.rsc' ,
1007- id : ( output . id === '/' ? '/index' : output . pathname ) + '.rsc' ,
1004+ pathname : normalizePagePath ( output . pathname ) + '.rsc' ,
1005+ id : normalizePagePath ( output . pathname ) + '.rsc' ,
10081006 } )
10091007 outputs . appPages . push ( output )
10101008 } else {
@@ -1058,15 +1056,18 @@ export async function handleBuildComplete({
10581056 }
10591057
10601058 if ( meta ?. segmentPaths ) {
1059+ const normalizedRoute = normalizePagePath ( route )
10611060 const segmentsDir = path . join (
10621061 appDistDir ,
1063- `${ route } ${ prefetchSegmentDirSuffix } `
1062+ `${ normalizedRoute } ${ prefetchSegmentDirSuffix } `
10641063 )
10651064
10661065 for ( const segmentPath of meta . segmentPaths ) {
10671066 const outputSegmentPath =
1068- path . join ( route + prefetchSegmentDirSuffix , segmentPath ) +
1069- prefetchSegmentSuffix
1067+ path . join (
1068+ normalizedRoute + prefetchSegmentDirSuffix ,
1069+ segmentPath
1070+ ) + prefetchSegmentSuffix
10701071
10711072 const fallbackPathname = path . join (
10721073 segmentsDir ,
@@ -1114,7 +1115,7 @@ export async function handleBuildComplete({
11141115 route : string ,
11151116 isAppPage : boolean
11161117 ) : Promise < AppRouteMeta > => {
1117- const basename = route . endsWith ( '/' ) ? `${ route } index` : route ;
1118+ const basename = route . endsWith ( '/' ) ? `${ route } index` : route
11181119 const meta : AppRouteMeta = isAppPage
11191120 ? JSON . parse (
11201121 await fs
@@ -1193,7 +1194,7 @@ export async function handleBuildComplete({
11931194
11941195 let filePath = path . join (
11951196 isAppPage ? appDistDir : pagesDistDir ,
1196- `${ route === '/' ? 'index' : route } .${ isAppPage && ! dataRoute ? 'body' : 'html' } `
1197+ `${ normalizePagePath ( route ) } .${ isAppPage && ! dataRoute ? 'body' : 'html' } `
11971198 )
11981199
11991200 // we use the static 404 for notFound: true if available
@@ -1269,7 +1270,7 @@ export async function handleBuildComplete({
12691270 if ( dataRoute ) {
12701271 let dataFilePath = path . join (
12711272 pagesDistDir ,
1272- `${ route === '/' ? 'index' : route } .json`
1273+ `${ normalizePagePath ( route ) } .json`
12731274 )
12741275
12751276 if ( isAppPage ) {
@@ -1594,16 +1595,18 @@ export async function handleBuildComplete({
15941595 prefixRouteKeys : true ,
15951596 includeSuffix : true ,
15961597 } )
1598+ const isDataRoute = dataRoutePages . has ( page )
1599+
15971600 const destination = path . posix . join (
15981601 '/' ,
15991602 config . basePath ,
1600- ...( dataRoutePages . has ( page ) ? [ `_next/data` , buildId ] : '' ) ,
1603+ ...( isDataRoute ? [ `_next/data` , buildId ] : '' ) ,
16011604 ...( page === '/'
16021605 ? [ shouldLocalize ? '$nextLocale.json' : 'index.json' ]
16031606 : [
16041607 shouldLocalize ? '$nextLocale' : '' ,
16051608 page +
1606- '.json' +
1609+ ( isDataRoute ? '.json' : '' ) +
16071610 getDestinationQuery ( routeRegex . routeKeys || { } ) ,
16081611 ] )
16091612 )
0 commit comments