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
trailingSlash: "always" changes external URLs #5087
Comments
A workaround right now is adding (To other maintainers: I hope I got the labels right.) |
I'm seeing similar problems, but it is even worse. I have a statically generated site and the HTML has the links right (no trailing slash), but on click, something adds the slash before navigating. This happens for external links, but also to internal links to static assets like PDFs. So |
Update: the |
You can use kit/packages/kit/src/runtime/client/client.js Line 1158 in 373ff63
I think, in your case I would use the download attribute.
Edit:
kit/packages/kit/src/runtime/client/client.js Line 1167 in 373ff63
|
Nice, the sveltekit-reload option looks like the "right" way to bypass the javascript navigation when that's needed and that will workaround. Appreciate the code reference. The function that adds the slash is here: kit/packages/kit/src/utils/url.js Line 49 in 373ff63
Seems like it could detect non-relative links easy enough, but unfortunately, I'm not sure how that function (or the navigate function that calls it) might be able to discern static assets from routes before adding the slash. For now I guess I'll go annotate all the links I can find that are broken, but hopefully someone with more experience in Svelte Kit can craft a fix. |
* only normalise internal URLs - fixes #5087 * add finally clause * i am losing my goddamn mind * fix
Describe the bug
When using configuration:
trailingSlash: "always"
then external URLs will also get a trailing slash.There is a workaround if you set some kind of taget to the anchor element. For example
target="_self"
but it's still a bug that shoud be fixed.Reproduction
You can see repro: https://sveltejs-kit-template-default-tq3lbk--3000.local.webcontainer.io/
"Click me" should link to the URL: https://example.com/foo.php?bar=baz&more=params
But it actually navigates to: https://example.com/foo.php/?bar=baz&more=params
Notice the extra slash before the question mark.
You can see source of this example: https://stackblitz.com/edit/sveltejs-kit-template-default-tq3lbk?file=src/lib/header/Header.svelte
Logs
No response
System Info
Severity
annoyance
Additional Information
No response
The text was updated successfully, but these errors were encountered: