File tree Expand file tree Collapse file tree 4 files changed +8
-8
lines changed Expand file tree Collapse file tree 4 files changed +8
-8
lines changed Original file line number Diff line number Diff line change @@ -209,10 +209,12 @@ export class App {
209209 if ( this . #manifest. assets . has ( url . pathname ) ) return undefined ;
210210 let pathname = this . #computePathnameFromDomain( request ) ;
211211 if ( ! pathname ) {
212- pathname = prependForwardSlash ( this . removeBase ( url . pathname ) ) ;
212+ pathname = this . removeBase ( url . pathname )
213+ if ( pathname !== '' || this . #manifest. base === '/' ) {
214+ pathname = prependForwardSlash ( pathname ) ;
215+ }
213216 }
214217 let routeData = matchRoute ( decodeURI ( pathname ) , this . #manifestData) ;
215-
216218 if ( ! routeData ) return undefined ;
217219 if ( allowPrerenderedRoutes ) {
218220 return routeData ;
Original file line number Diff line number Diff line change @@ -38,7 +38,7 @@ export function getPattern(
3838 const trailing =
3939 addTrailingSlash && segments . length ? getTrailingSlashPattern ( addTrailingSlash ) : '$' ;
4040 let initial = '\\/' ;
41- if ( addTrailingSlash === 'never' && base !== '/' && pathname !== '' ) {
41+ if ( addTrailingSlash === 'never' && base !== '/' ) {
4242 initial = '' ;
4343 }
4444 return new RegExp ( `^${ pathname || initial } ${ trailing } ` ) ;
Original file line number Diff line number Diff line change @@ -30,7 +30,6 @@ export function baseMiddleware(
3030
3131 if ( pathname . startsWith ( devRoot ) ) {
3232 req . url = url . replace ( devRoot , devRootReplacement ) ;
33- req . url ||= '/' ;
3433 return next ( ) ;
3534 }
3635
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" matches the index route when it contains a trailing slash' , async ( ) => {
40+ it ( 'using trailingSlash: "never" does not match 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,9 +51,8 @@ describe('routing - createRoutesList', () => {
5151 settings,
5252 } ) ;
5353 const [ { pattern } ] = manifest . routes ;
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 ) ;
54+ assert . equal ( pattern . test ( '' ) , true ) ;
55+ assert . equal ( pattern . test ( '/' ) , false ) ;
5756 } ) ;
5857
5958 it ( 'endpoint routes are sorted before page routes' , async ( ) => {
You can’t perform that action at this time.
0 commit comments