Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/full-cloths-sleep.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro': patch
---

Fixes a bug that caused index pages to not be found when a base was set with trailingSlash: never
2 changes: 1 addition & 1 deletion packages/astro/src/core/routing/manifest/pattern.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export function getPattern(
const trailing =
addTrailingSlash && segments.length ? getTrailingSlashPattern(addTrailingSlash) : '$';
let initial = '\\/';
if (addTrailingSlash === 'never' && base !== '/') {
if (addTrailingSlash === 'never' && base !== '/' && pathname !== '') {
initial = '';
}
return new RegExp(`^${pathname || initial}${trailing}`);
Expand Down
4 changes: 1 addition & 3 deletions packages/astro/test/ssr-trailing-slash.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,9 +255,7 @@ describe('Redirecting trailing slashes in SSR', () => {
const app = await fixture.loadTestAdapterApp();
const request = new Request('http://example.com/mybase');
const response = await app.render(request);
// Should not redirect, but will 404 since we don't have an index page
assert.notEqual(response.status, 301);
assert.notEqual(response.status, 308);
assert.equal(response.status, 200);
});

it('Redirects to remove trailing slash on sub-paths with base', async () => {
Expand Down
Loading