Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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: 0 additions & 5 deletions packages/astro/src/i18n/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -399,11 +399,6 @@ export function redirectToFallback({
if (pathFallbackLocale === defaultLocale && strategy === 'pathname-prefix-other-locales') {
if (context.url.pathname.includes(`${base}`)) {
newPathname = context.url.pathname.replace(`/${urlLocale}`, ``);
// Ensure the pathname are non-empty. Redirects like "/fr" => "" may create infinite loops,
// as the "Location" response header is empty.
if (newPathname === '') {
newPathname = '/';
}
} else {
newPathname = context.url.pathname.replace(`/${urlLocale}`, `/`);
}
Expand Down
44 changes: 0 additions & 44 deletions packages/astro/test/i18n-routing.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -774,50 +774,6 @@ describe('[SSG] i18n routing', () => {
});
});

describe('i18n routing with routing strategy [prefix-other-locales] with root base', () => {
/** @type {import('./test-utils').Fixture} */
let fixture;
/** @type {import('./test-utils').DevServer} */
let devServer;

before(async () => {
fixture = await loadFixture({
root: './fixtures/i18n-routing-prefix-other-locales/',
output: 'server',
adapter: testAdapter(),
base: '/',
i18n: {
defaultLocale: 'en',
locales: ['en', 'pt', 'fr'],
fallback: {
fr: 'en',
},
routing: {
prefixDefaultLocale: false,
redirectToDefaultLocale: true,
fallbackType: 'redirect',
},
},
});
await fixture.build();
devServer = await fixture.startDevServer();
});

afterEach(async () => {
devServer.stop();
});

it('should redirect to English page', async () => {
const response = await fixture.fetch('/fr', { redirect: 'manual' });
assert.equal(response.headers.get('Location'), '/');
assert.equal(response.status, 302);

const followRedirectResponse = await fixture.fetch('/fr');
assert.equal(followRedirectResponse.status, 200);
assert.equal((await followRedirectResponse.text()).includes('Hello'), true);
});
});

describe('i18n routing with routing strategy [pathname-prefix-always-no-redirect]', () => {
/** @type {import('./test-utils').Fixture} */
let fixture;
Expand Down
Loading