-
-
Notifications
You must be signed in to change notification settings - Fork 245
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Handle edge case for localePrefix: 'as-needed'
, domains
& pathnames
#1594
base: main
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
expect(MockedNextResponse.redirect.mock.calls[0][0].toString()).toBe( | ||
'http://en.example.com/about' | ||
); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@markomitranic I've tried to recreate your case here.
See also the config above:
next-intl/packages/next-intl/src/middleware/middleware.test.tsx
Lines 2652 to 2705 in 101bb5e
const middlewareWithPathnames = createMiddleware({ | |
defaultLocale: 'en', | |
locales: ['en', 'fr'], | |
localePrefix: 'as-needed', | |
domains: [ | |
{defaultLocale: 'en', domain: 'en.example.com', locales: ['en']}, | |
{ | |
defaultLocale: 'en', | |
domain: 'ca.example.com', | |
locales: ['en', 'fr'] | |
}, | |
{defaultLocale: 'fr', domain: 'fr.example.com', locales: ['fr']} | |
], | |
pathnames: { | |
'/': '/', | |
'/about': { | |
en: '/about', | |
fr: '/a-propos' | |
}, | |
'/users': { | |
en: '/users', | |
fr: '/utilisateurs' | |
}, | |
'/users/[userId]': { | |
en: '/users/[userId]', | |
fr: '/utilisateurs/[userId]' | |
}, | |
'/news/[articleSlug]-[articleId]': { | |
en: '/news/[articleSlug]-[articleId]', | |
fr: '/nouvelles/[articleSlug]-[articleId]' | |
}, | |
'/products/[...slug]': { | |
en: '/products/[...slug]', | |
fr: '/produits/[...slug]' | |
}, | |
'/categories/[[...slug]]': { | |
en: '/categories/[[...slug]]', | |
fr: '/categories/[[...slug]]' | |
}, | |
'/internal': '/external', | |
'/internal/foo/bar': { | |
en: '/external-en/foo/bar', | |
fr: '/external-fr/foo/bar' | |
}, | |
'/internal/[id]': { | |
en: '/external-en/[id]', | |
fr: '/external-fr/[id]' | |
}, | |
'/internal/[...slug]': { | |
en: '/external-en/[...slug]', | |
fr: '/external-fr/[...slug]' | |
} | |
} satisfies Pathnames<ReadonlyArray<'en' | 'fr'>> | |
}); |
This seems to be working for me. A redirect to /about
is currently added here for compatibility, e.g. when the user switches the domain without changing pathnames.
Can you help me find a failing test?
Related to #1107 (comment)
Couldn't find the bug yet, only added tests so far.