From 101bb5ee0874beafd08c31c4fa3b6596a9efd1e1 Mon Sep 17 00:00:00 2001 From: Jan Amann Date: Thu, 5 Dec 2024 11:43:02 +0100 Subject: [PATCH 1/2] add tests --- .../src/middleware/middleware.test.tsx | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/packages/next-intl/src/middleware/middleware.test.tsx b/packages/next-intl/src/middleware/middleware.test.tsx index 7449040eb..6b01bc4da 100644 --- a/packages/next-intl/src/middleware/middleware.test.tsx +++ b/packages/next-intl/src/middleware/middleware.test.tsx @@ -2704,6 +2704,27 @@ describe('domain-based routing', () => { } satisfies Pathnames> }); + it('redirects an unprefixed pathname from the fr locale on the en domain', () => { + middlewareWithPathnames( + createMockRequest('/a-propos', 'fr', 'http://en.example.com') + ); + expect(MockedNextResponse.redirect).toHaveBeenCalled(); + expect(MockedNextResponse.redirect.mock.calls[0][0].toString()).toBe( + 'http://en.example.com/about' + ); + }); + + it('redirects a prefixed pathname from the fr locale on the en domain', () => { + middlewareWithPathnames( + createMockRequest('/fr/a-propos', 'fr', 'http://en.example.com') + ); + expect(MockedNextResponse.redirect).toHaveBeenCalled(); + expect(MockedNextResponse.redirect.mock.calls[0][0].toString()).toBe( + // (will get another redirect to /a-propos on this domain) + 'http://fr.example.com/fr/a-propos' + ); + }); + it('serves requests for the default locale at the root', () => { middlewareWithPathnames( createMockRequest('/', 'en', 'http://en.example.com') From e32ded857d886e9fb951d435217cb575fd235f30 Mon Sep 17 00:00:00 2001 From: Jan Amann Date: Thu, 5 Dec 2024 11:48:39 +0100 Subject: [PATCH 2/2] bump size --- packages/next-intl/.size-limit.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/next-intl/.size-limit.ts b/packages/next-intl/.size-limit.ts index 94f0cf398..5acc429c3 100644 --- a/packages/next-intl/.size-limit.ts +++ b/packages/next-intl/.size-limit.ts @@ -45,7 +45,7 @@ const config: SizeLimitConfig = [ name: "import {createNavigation} from 'next-intl/navigation' (react-server)", path: 'dist/production/navigation.react-server.js', import: '{createNavigation}', - limit: '16.8 KB' + limit: '16.815 KB' }, { name: "import * from 'next-intl/server' (react-client)",