diff --git a/packages/astro/src/vite-plugin-astro-server/index.ts b/packages/astro/src/vite-plugin-astro-server/index.ts index b718780798..506f54a3fb 100644 --- a/packages/astro/src/vite-plugin-astro-server/index.ts +++ b/packages/astro/src/vite-plugin-astro-server/index.ts @@ -194,9 +194,10 @@ async function handleRequest( // When file-based build format is used, pages will be built to `/blog.html` // rather than `/blog/index.html`. The dev server should handle this as well // to match production deployments. - const url = config.build.format === 'file' - ? new URL(origin + req.url?.replace(/(index)?\.html$/, '')) - : new URL(origin + req.url); + const url = + config.build.format === 'file' + ? new URL(origin + req.url?.replace(/(index)?\.html$/, '')) + : new URL(origin + req.url); const pathname = decodeURI(url.pathname); const rootRelativeUrl = pathname.substring(devRoot.length - 1); if (!buildingToSSR) { diff --git a/packages/astro/test/dev-routing.test.js b/packages/astro/test/dev-routing.test.js index de765a1830..13ea4d12fe 100644 --- a/packages/astro/test/dev-routing.test.js +++ b/packages/astro/test/dev-routing.test.js @@ -289,7 +289,7 @@ describe('Development Routing', () => { const response = await fixture.fetch('/1.html'); expect(response.status).to.equal(200); }); - + it('200 when loading /1', async () => { const response = await fixture.fetch('/1'); expect(response.status).to.equal(200);