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

getRelativeLocaleUrl returns an empty string #13035

Open
1 task
mversic opened this issue Jan 21, 2025 · 1 comment
Open
1 task

getRelativeLocaleUrl returns an empty string #13035

mversic opened this issue Jan 21, 2025 · 1 comment
Labels
- P4: important Violate documented behavior or significantly impacts performance (priority) feat: i18n Related to internalization (scope)

Comments

@mversic
Copy link

mversic commented Jan 21, 2025

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

getRelativeLocaleUrl('en') (where en is the defaultLocale) returns an empty string. This is a problem because href cannot be empty as for example in a link tag <a href={getRelativeLocaleUrl('en')}>. This would give <a href=""> when I expected <a href="/">

This is my astro config:

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

What's the expected result?

getRelativeLocaleUrl('en') returns "/" because an empty string is not a valid relative URL as demonstrated with the <a> tag

Link to Minimal Reproducible Example

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

Participation

  • I am willing to submit a pull request for this issue.
@github-actions github-actions bot added the needs triage Issue needs to be triaged label Jan 21, 2025
@mversic mversic changed the title getRelativeLocale returns an empty string getRelativeLocaleUrl returns an empty string Jan 21, 2025
@mversic
Copy link
Author

mversic commented Jan 21, 2025

also make sure that getAbsoluteLocaleUrl('en') doesn't return empty string when site is not defined in the config

@ematipico ematipico added - P4: important Violate documented behavior or significantly impacts performance (priority) feat: i18n Related to internalization (scope) labels Jan 21, 2025
@github-actions github-actions bot removed the needs triage Issue needs to be triaged label Jan 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- P4: important Violate documented behavior or significantly impacts performance (priority) feat: i18n Related to internalization (scope)
Projects
None yet
Development

No branches or pull requests

2 participants