summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.changeset/tiny-dodos-melt.md5
-rw-r--r--packages/astro/src/vite-plugin-astro-server/route.ts5
-rw-r--r--packages/astro/test/dev-routing.test.js5
-rw-r--r--packages/astro/test/fixtures/without-site-config/src/pages/base-index.astro1
4 files changed, 15 insertions, 1 deletions
diff --git a/.changeset/tiny-dodos-melt.md b/.changeset/tiny-dodos-melt.md
new file mode 100644
index 000000000..66d4717b6
--- /dev/null
+++ b/.changeset/tiny-dodos-melt.md
@@ -0,0 +1,5 @@
+---
+"astro": patch
+---
+
+Fix loading of non-index routes that end with `index.html`
diff --git a/packages/astro/src/vite-plugin-astro-server/route.ts b/packages/astro/src/vite-plugin-astro-server/route.ts
index 85bf969f9..cc8439fa5 100644
--- a/packages/astro/src/vite-plugin-astro-server/route.ts
+++ b/packages/astro/src/vite-plugin-astro-server/route.ts
@@ -81,7 +81,10 @@ export async function matchRoute(
// Try without `.html` extensions or `index.html` in request URLs to mimic
// routing behavior in production builds. This supports both file and directory
// build formats, and is necessary based on how the manifest tracks build targets.
- const altPathname = pathname.replace(/(?:index)?\.html$/, '');
+ const altPathname = pathname
+ .replace(/\/index\.html$/, '/')
+ .replace(/\.html$/, '');
+
if (altPathname !== pathname) {
return await matchRoute(altPathname, manifestData, pipeline);
}
diff --git a/packages/astro/test/dev-routing.test.js b/packages/astro/test/dev-routing.test.js
index cc0a3fa1c..c6a19fc4e 100644
--- a/packages/astro/test/dev-routing.test.js
+++ b/packages/astro/test/dev-routing.test.js
@@ -321,6 +321,11 @@ describe('Development Routing', () => {
assert.equal(response.status, 200);
});
+ it('200 when loading /base-index.html', async () => {
+ const response = await fixture.fetch('/base-index.html');
+ assert.equal(response.status, 200);
+ });
+
it('200 when loading /', async () => {
const response = await fixture.fetch('/');
assert.equal(response.status, 200);
diff --git a/packages/astro/test/fixtures/without-site-config/src/pages/base-index.astro b/packages/astro/test/fixtures/without-site-config/src/pages/base-index.astro
new file mode 100644
index 000000000..76e198f3d
--- /dev/null
+++ b/packages/astro/test/fixtures/without-site-config/src/pages/base-index.astro
@@ -0,0 +1 @@
+<div>testing</div>