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

Pathnames with 2 dynamics values of the same name require 2 different params #1236

Closed
3 tasks done
Rheaparks opened this issue Aug 5, 2024 · 1 comment · Fixed by #1259
Closed
3 tasks done

Pathnames with 2 dynamics values of the same name require 2 different params #1236

Rheaparks opened this issue Aug 5, 2024 · 1 comment · Fixed by #1259
Labels
bug Something isn't working unconfirmed Needs triage.

Comments

@Rheaparks
Copy link

Rheaparks commented Aug 5, 2024

Description

I need to use the same dynamic param twice. But even if it is the same param, the getPathname() is asking two params. I can't obviously enter the same param twice… Is it my mistake?

Here is the pathname code:

    "/seo/things-to-do/[countrySlug]": {
      en:"/[countrySlug]/things-to-do-[countrySlug]",
      fr:"/[countrySlug]/que-faire-[countrySlug]",
    },

The error:

Error: Insufficient params provided for localized pathname.
Template: /[countrySlug]/que-faire-[countrySlug]
Params: {"countrySlug":"france"}

Verifications

  • I've verified that the problem I'm experiencing isn't covered in the docs.
  • I've searched for similar, existing issues on GitHub and Stack Overflow.
  • I've compared my app to a working example to look for differences.

Mandatory reproduction URL

https://github.com/amannn/next-intl-bug-repro-app-router

Reproduction description

Steps to reproduce:

  1. On environment { Pathnames } next-intl/routing
  2. Create a pathname with config or navigation.ts like this:
"/seo/things-to-do/[countrySlug]": {
      en:"/[countrySlug]/things-to-do-[countrySlug]",
      fr:"/[countrySlug]/que-faire-[countrySlug]",
 },
  1. Create app > [locale] > seo > things-to-do > [countrySlug] > page.tsx
  2. Call:
const path = getPathname({
    locale: locale,
    href: {
      pathname: "/seo/things-to-do/[countrySlug]"
      params: { countrySlug: "france" }
    },
  } as any);
  1. See error:
Error: Insufficient params provided for localized pathname.
Template: /[countrySlug]/que-faire-[countrySlug]
Params: {"countrySlug":"france"}

Expected behaviour

We enter only one param, since it is the same param called twice.

@amannn
Copy link
Owner

amannn commented Aug 14, 2024

Thanks for the report! A fix is coming in #1259

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working unconfirmed Needs triage.
Projects
None yet
2 participants