diff --git a/examples/example-app-router-playground/.gitignore b/examples/example-app-router-playground/.gitignore index ef113c3c..d6187378 100644 --- a/examples/example-app-router-playground/.gitignore +++ b/examples/example-app-router-playground/.gitignore @@ -4,3 +4,4 @@ tsconfig.tsbuildinfo *storybook.log storybook-static +test-results diff --git a/examples/example-app-router-playground/playwright.config.ts b/examples/example-app-router-playground/playwright.config.ts index cdd5c90b..e6a7e800 100644 --- a/examples/example-app-router-playground/playwright.config.ts +++ b/examples/example-app-router-playground/playwright.config.ts @@ -5,6 +5,9 @@ import {devices} from '@playwright/test'; // Use a distinct port on CI to avoid conflicts during concurrent tests const PORT = process.env.CI ? 3004 : 3000; +// Forward to specs +process.env.PORT = PORT.toString(); + const config: PlaywrightTestConfig = { retries: process.env.CI ? 1 : 0, testMatch: process.env.TEST_MATCH || 'main.spec.ts', diff --git a/examples/example-app-router-playground/tests/domains.spec.ts b/examples/example-app-router-playground/tests/domains.spec.ts index fa01bf3f..f1aac49d 100644 --- a/examples/example-app-router-playground/tests/domains.spec.ts +++ b/examples/example-app-router-playground/tests/domains.spec.ts @@ -16,7 +16,7 @@ it('can use config based on the default locale on an unknown domain', async ({ it('can use a secondary locale unprefixed if the domain has specified it as the default locale', async () => { const browser = await chromium.launch({ - args: ['--host-resolver-rules=MAP example.de 127.0.0.1:3000'] + args: ['--host-resolver-rules=MAP example.de 127.0.0.1:' + process.env.PORT] }); const page = await browser.newPage(); @@ -24,7 +24,7 @@ it('can use a secondary locale unprefixed if the domain has specified it as the route.continue({ headers: { 'accept-language': 'de', - 'x-forwarded-port': '80' + 'x-forwarded-port': '80' // (playwright default) } }) ); diff --git a/packages/next-intl/src/navigation/shared/BaseLink.tsx b/packages/next-intl/src/navigation/shared/BaseLink.tsx index c19bd936..7ce46d92 100644 --- a/packages/next-intl/src/navigation/shared/BaseLink.tsx +++ b/packages/next-intl/src/navigation/shared/BaseLink.tsx @@ -37,10 +37,10 @@ function BaseLink( // If there is an `unprefixed` prop, the // `defaultLocale` might differ by domain unprefixed && - // Unprefix the pathname if a domain + // Unprefix the pathname if a domain matches (unprefixed.domains[host] === linkLocale || - // For unknown domains, remove the prefix for the global - // `defaultLocale` (e.g. on localhost) + // … and handle unknown domains by applying the + // global `defaultLocale` (e.g. on localhost) (!Object.keys(unprefixed.domains).includes(host) && curLocale === defaultLocale && !locale))