Skip to content

getRelativeLocaleUrl apends trailing slash even with trailingSlash: 'never' #13032

Description

@mversic

Astro Info

Astro                    v5.1.7
Node                     v23.5.0
System                   macOS (arm64)
Package Manager          pnpm
Output                   static
Adapter                  none
Integrations

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

No response

Describe the Bug

This is my astro.config.ts:

export default defineConfig({
  trailingSlash: 'never',
  i18n: {
    locales: ['en', 'fr'],
    defaultLocale: 'en',
  },
});

using getRelativeLocaleUrl('fr', '') or getRelativeLocaleUrl('fr', '/') returns /fr/ (a string with a trailing slash) even though trailingSlash: never is set in the config. The same goes for getAbsoluteLocaleUrl

What's the expected result?

If I defined trailingSlash: never, I expect that getRelativeLocaleUrl and getAbsoluteLocaleUrl return paths without a trailing slash (with the possible exception of the root path)

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-bvnpwdin

Participation

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    - P3: minor bugAn edge case that only affects very specific usage (priority)feat: i18nRelated to internalization (scope)good first issueGood for newcomers. If you need additional guidance, feel free to post in #contribute on Discord

    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