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
i18n: language switch works on dev server, but built links may include double leading slash #10630
Comments
I can't tell if there's an issue here with one of our i18n APIs or if it's a bug in your code. Which Astro API seems to be the problem? |
Look at it more, it looks like the reason you are getting the extra |
Thanks, @matthewp! Yeah, that makes sense and works. What really makes no sense to me at all is, why this introduces trailing slashes to the urls?!? When I build your edit (not in dev server), the language switch links have all trailing slashes: dist/index.html --> href="/en/" These links are built with |
It's because the param gets turned into the url so that |
I got that, but I don't get why there is suddenly a slash at the end of URLs when I build your example. |
Found your answer: #4638 (comment) For the record: Setting build.format controls what Astro.url is set to during the build. When it is Still weird, that it didn't add a trailing slash when my getStaticPaths function was buggy, but only when it was fixed. Anyway, moving on. |
Astro Info
If this issue only occurs in one browser, which browser is a problem?
No response
Describe the Bug
I have a simple language switch:
It works without issues in dev mode, but when I build the site, I get double leading slashes under some circumstances.
Usage of minimal repro
/en/about
(click "EN", then "about page")npm run build && npm run preview
/en/about
, the "DE" link is now broken:https://about/
.dist/en/about/index.html
includes the linka href="//about/"> DE </a
, all the other language switch links created are correct.This might be related to #10621, since I get it in the same project.
What's the expected result?
Build should produce the correct link.
Link to Minimal Reproducible Example
https://stackblitz.com/edit/withastro-astro-fs5dhp?file=src%2Fcomponents%2FLanguageSwitch.astro
Participation
The text was updated successfully, but these errors were encountered: