Skip to content

Commit b6376cb

Browse files
committed
Fix dev handling
1 parent 6a238b9 commit b6376cb

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

packages/astro/src/vite-plugin-astro-server/base.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff 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

packages/astro/test/units/routing/manifest.test.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ function assertRouteRelations(routes, relations) {
3737
}
3838

3939
describe('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 () => {

0 commit comments

Comments
 (0)