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

import.meta.env.BASE_URL is including a trailing slash #6623

Closed
1 task
sugarmaplemedia opened this issue Mar 21, 2023 · 4 comments
Closed
1 task

import.meta.env.BASE_URL is including a trailing slash #6623

sugarmaplemedia opened this issue Mar 21, 2023 · 4 comments
Assignees
Labels
- P3: minor bug An edge case that only affects very specific usage (priority) semver: major Change triggers a `major` release

Comments

@sugarmaplemedia
Copy link

What version of astro are you using?

2.1.4

Are you using an SSR adapter? If so, which one?

None

What package manager are you using?

npm

What operating system are you using?

Windows

What browser are you using?

Firefox

Describe the Bug

When I call import.meta.env.BASE_URL in my src files, it includes a trailing slash that renders incorrectly as http://localhost/foo//bar.

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-wccs8f?file=src/pages/index.astro

Participation

  • I am willing to submit a pull request for this issue.
@sugarmaplemedia
Copy link
Author

Update: setting trailingSlash in the config from the default ignore to never fixed the issue. Either way, its still a bug.

@bluwy
Copy link
Member

bluwy commented Mar 22, 2023

Makes sense to me. Looks like the behaviour was from #5358, even though before it we had always prepend a slash. But I agree that if the default is ignore, it should probably leave the base as is.

There's a good chance someone might be relying on the old behaviour though so "fixing" this could be a breaking change.

@bluwy bluwy self-assigned this Mar 22, 2023
@bluwy
Copy link
Member

bluwy commented Mar 22, 2023

I've got a fix for this, which when using trailingSlash: "ignore", the slashes in the base is preserved as is. Branch.

It changes a test to pass though, so I think this is indeed a breaking change, and would have to keep it till the next major.

@natemoo-re
Copy link
Member

Closing this since #7878 has been merged to next. This will be fixed in Astro 3.0!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- P3: minor bug An edge case that only affects very specific usage (priority) semver: major Change triggers a `major` release
Projects
None yet
Development

No branches or pull requests

3 participants