Skip to content

The route functions from astro:i18n are adding a trailing slash when it's not supposed to #9919

Description

@kevintakeda

Astro Info

Astro                    v4.2.8
Node                     v18.18.0
System                   Linux (x64)
Package Manager          unknown
Output                   static
Adapter                  none
Integrations             @astrojs/mdx
                         @astrojs/sitemap

If this issue only occurs in one browser, which browser is a problem?

Chrome

Describe the Bug

Using the config below, getRelativeLocaleUrl("es", "/") outputs /es/ instead of /es. It seems that this only happens with the home path. This also affects the other i18n functions.

const config = {
  trailingSlash: 'never',
  build: {
    format: 'file',
  },
  i18n: {
    defaultLocale: "en",
    locales: ["en", "es"],
    routing: {
      prefixDefaultLocale: false,
    }
  }

What's the expected result?

I expected that trailingSlash: 'never' option should never output urls with trailing slash.

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-xz2dyx?file=astro.config.mjs

Participation

  • I am willing to submit a pull request for this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    - P2: has workaroundAn edge case that only affects very specific usage, but has a trivial workaround (priority)

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions