Skip to content

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

@derBlume

Description

@derBlume

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs triageIssue needs to be triaged

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions