Skip to content

Conversation

@jp-knj
Copy link
Member

@jp-knj jp-knj commented May 3, 2025

Changes

  • Fix Astro.url.pathname returns trailing slash on index page when base is set and trailingSlash is 'never' #13736: when base: '/base' is used with trailingSlash: 'never', the root page now returns /base (no trailing slash) instead of /base/.

  • Path helpers updated

    • astro/src/core/runtime/utils/path.ts
    • internal-helpers/src/path.ts
      Both helper functions now:
    • keep / untouched
    • remove exactly one trailing slash from any other path
  • Unit-test enhanced

    • packages/astro/test/units/routing/trailing-slash.test.js

      • adds an echo handler for /
      • new assertion confirms the pathname is /base
  • No behaviour change for trailingSlash: 'always' or non-root routes.

Changeset generated: pnpm exec changeset (patch release)


Testing

  • Rebuilt helpers & core:
    pnpm --filter internal-helpers build && pnpm --filter astro build
  • Ran updated suite:
    node --test packages/astro/test/units/routing-trailing-slash.test.jsall 9 tests pass (1 failed before).
  • Full repo: pnpm test → green.

No additional e2e required; unit test covers the regression.


Docs

No doc updates required—behaviour now matches existing documentation.

@github-actions github-actions bot added the pkg: astro Related to the core `astro` package (scope) label May 3, 2025
@changeset-bot
Copy link

changeset-bot bot commented May 3, 2025

⚠️ No Changeset found

Latest commit: 9f4b540

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@jp-knj jp-knj closed this May 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pkg: astro Related to the core `astro` package (scope)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant