Skip to content
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 overlapping custom locale prefixes correctly #1343

Merged
merged 2 commits into from
Sep 17, 2024

Conversation

amannn
Copy link
Owner

@amannn amannn commented Sep 17, 2024

Consider this config:

export const routing = defineRouting({
  locales: ["en-US", "es-US"],
  defaultLocale: "en-US",
  localePrefix: {
    mode: "always",
    prefixes: {
      "es-US": "/us/es",
      "en-US": "/us"
    },
  }
});

… a pathname like /us/es would previously be incorrectly rewritten to /en-US/es internally. With this change, we now prioritize more specific prefixes in order to rewrite this request correctly to /es-US.

Fixes #1329

Copy link

vercel bot commented Sep 17, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
next-intl-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 17, 2024 9:13am
next-intl-example-app-router ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 17, 2024 9:13am
next-intl-example-app-router-without-i18n-routing ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 17, 2024 9:13am

@amannn amannn marked this pull request as ready for review September 17, 2024 09:10
@amannn amannn changed the title fix: Handle overlapping locale prefixes correctly fix: Handle overlapping custom locale prefixes correctly Sep 17, 2024
@amannn amannn merged commit 72c1731 into main Sep 17, 2024
6 of 7 checks passed
amannn added a commit that referenced this pull request Sep 17, 2024
Follow-up for #1343, as the
issue was only addressed partially before.

Closes #1329
@amannn amannn deleted the fix/overlapping-locale-prefixes branch October 24, 2024 13:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

localePrefix doesn't support "es-US" prefixed locale
1 participant