Skip to content

Astro.url.pathname returns trailing slash on index page when base is set and trailingSlash is 'never' #13736

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

Open
1 task
derBlume opened this issue Apr 30, 2025 · 0 comments
Labels
needs triage Issue needs to be triaged

Comments

@derBlume
Copy link

Astro Info

Astro                    v5.7.10
Node                     v20.19.0
System                   macOS (x64)
Package Manager          unknown
Output                   server
Adapter                  @astrojs/node
Integrations             @sentry/astro

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

No response

Describe the Bug

The bug I described in #13585 unfortunately still remains in v5.7.0 upwards. At first I thought, that the fix for the regression apparently introduced with the fix for the original issue (#13633) may have caused a regression for the original issue again. But that does not seem to be the case. It neither works as I would expect in v5.7.0, v5.7.2 nor the most recent v5.7.10.

For convenience, the original bug description:

When configured with a base path 'base' and trailingSlash set to 'never', Astro.url.pathname returns /base/ for the root path, while import.meta.env.BASE_URL correctly respects the trailingSlash setting and returns /base, just as document.location.pathname does.

Also, what i commented in the original issue as a presumably related problem still is the case:

If the project is configured as described in the original issue and built with output set to 'server' using the node adapter in 'standalone' mode, the index page does not work at all but returns a 404.

If trailingSlash is set to 'ignore', and then the server is built with the node adapter, Astro.url.pathname behaves correctly and returns /base/ or /base respectivly, always reflecting the url actually used.

If you think this second bit is not connected and rather a separate issue, let me know.

What's the expected result?

In the above example Astro.url.pathname should return '/base'

Link to Minimal Reproducible Example

https://stackblitz.com/edit/withastro-astro-a5kvvtuy?file=astro.config.mjs

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 Apr 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs triage Issue needs to be triaged
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant