Skip to content

DynamicLink produces double slash in href when default locale is hidden (hideLocale: 'default-locale') #3018

@ZDSJdeJT

Description

@ZDSJdeJT

To Reproduce

  1. Configure Fumadocs i18n with the core middleware and set hideLocale: 'default-locale' so the default language has no locale segment in the URL (e.g. /docs/page for default, /zh/docs/page for other locales).
  2. On a page under the default locale (address bar shows a path without a locale segment, e.g. /docs/something), add a link using the dynamic-link component with an href that includes a dynamic segment such as /[lang]/docs/other-page (import DynamicLink from fumadocs-core/dynamic-link and set href="/[lang]/docs/other-page").
  3. Load the page and check the rendered link’s href in the DOM or by hovering/clicking the link.

Current vs. Expected behavior

  • Current: The link href is //docs/other-page (double slash). When the default locale is hidden, useParams() does not provide lang, so [lang] is replaced with an empty string, producing a malformed URL.
  • Expected: The link should be /docs/other-page (single slash). When the locale segment is omitted for the default language, the path should be normalized so there are no consecutive slashes.

Provide environment information

Operating System:
  Platform: win32
  Version: Windows 11

Binaries:
  Node: 24.13.1
  pnpm: 10.18.3

Which area(s) are affected? (Select all that apply)

Core

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions