mirror of
https://github.com/withastro/astro.git
synced 2025-03-31 23:31:30 -05:00
Fix loading of non-index routes that end with index.html
(#10979)
* Add test * Fix alt pathname * Add changeset
This commit is contained in:
parent
370b9f1612
commit
6fa89e84c9
4 changed files with 15 additions and 1 deletions
5
.changeset/tiny-dodos-melt.md
Normal file
5
.changeset/tiny-dodos-melt.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
"astro": patch
|
||||
---
|
||||
|
||||
Fix loading of non-index routes that end with `index.html`
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
1
packages/astro/test/fixtures/without-site-config/src/pages/base-index.astro
vendored
Normal file
1
packages/astro/test/fixtures/without-site-config/src/pages/base-index.astro
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
<div>testing</div>
|
Loading…
Add table
Reference in a new issue