File tree Expand file tree Collapse file tree 2 files changed +5
-3
lines changed
src/vite-plugin-astro-server Expand file tree Collapse file tree 2 files changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -30,6 +30,7 @@ export function baseMiddleware(
3030
3131 if ( pathname . startsWith ( devRoot ) ) {
3232 req . url = url . replace ( devRoot , devRootReplacement ) ;
33+ req . url ||= '/' ;
3334 return next ( ) ;
3435 }
3536
Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ function assertRouteRelations(routes, relations) {
3737}
3838
3939describe ( 'routing - createRoutesList' , ( ) => {
40- it ( 'using trailingSlash: "never" does not match the index route when it contains a trailing slash' , async ( ) => {
40+ it ( 'using trailingSlash: "never" matches the index route when it contains a trailing slash' , async ( ) => {
4141 const fixture = await createFixture ( {
4242 '/src/pages/index.astro' : `<h1>test</h1>` ,
4343 } ) ;
@@ -51,8 +51,9 @@ describe('routing - createRoutesList', () => {
5151 settings,
5252 } ) ;
5353 const [ { pattern } ] = manifest . routes ;
54- assert . equal ( pattern . test ( '' ) , true ) ;
55- assert . equal ( pattern . test ( '/' ) , false ) ;
54+ // Requesting `/` *should* match the index route, because that's what it sees when requesting `/search`.
55+ // If they've requested `/search/` this will have been caught by trailingSlashMiddleware
56+ assert . equal ( pattern . test ( '/' ) , true ) ;
5657 } ) ;
5758
5859 it ( 'endpoint routes are sorted before page routes' , async ( ) => {
You can’t perform that action at this time.
0 commit comments