@@ -158,16 +158,15 @@ export async function createFixture(init: FixtureInit, mode?: ServerMode) {
158158 prerender : init . prerender ,
159159 requestDocument ( href : string ) {
160160 let file = new URL ( href , "test://test" ) . pathname + "/index.html" ;
161- let mainPath = path . join ( projectDir , "build" , "client" , file ) ;
162- let fallbackPath = path . join (
163- projectDir ,
164- "build" ,
165- "client" ,
166- "__spa-fallback.html" ,
167- ) ;
161+ let clientDir = path . join ( projectDir , "build" , "client" ) ;
162+ let mainPath = path . join ( clientDir , file ) ;
163+ let fallbackPath = path . join ( clientDir , "__spa-fallback.html" ) ;
164+ let fallbackPath2 = path . join ( clientDir , "index.html" ) ;
168165 let html = existsSync ( mainPath )
169166 ? readFileSync ( mainPath )
170- : readFileSync ( fallbackPath ) ;
167+ : existsSync ( fallbackPath )
168+ ? readFileSync ( fallbackPath )
169+ : readFileSync ( fallbackPath2 ) ;
171170 return new Response ( html , {
172171 headers : {
173172 "Content-Type" : "text/html" ,
@@ -344,11 +343,18 @@ export async function createAppFixture(fixture: Fixture, mode?: ServerMode) {
344343 ) ;
345344 app . get ( "*" , ( req , res , next ) => {
346345 let dir = path . join ( fixture . projectDir , "build" , "client" ) ;
347- let file = req . path . endsWith ( ".data" )
348- ? req . path
349- : req . path + "/index.html" ;
350- if ( file . endsWith ( ".html" ) && ! existsSync ( path . join ( dir , file ) ) ) {
351- file = "__spa-fallback.html" ;
346+ let file ;
347+ if ( req . path . endsWith ( ".data" ) ) {
348+ file = req . path ;
349+ } else {
350+ let mainPath = req . path + "/index.html" ;
351+ let fallbackPath = "__spa-fallback.html" ;
352+ let fallbackPath2 = "index.html" ;
353+ file = existsSync ( mainPath )
354+ ? mainPath
355+ : existsSync ( fallbackPath )
356+ ? fallbackPath
357+ : fallbackPath2 ;
352358 }
353359 let filePath = path . join ( dir , file ) ;
354360 if ( existsSync ( filePath ) ) {
0 commit comments