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

fix: respect trailing slash option when navigating from the root page of the basepath #11388

Merged
merged 5 commits into from
Jan 9, 2024

Conversation

eltigerchino
Copy link
Member

@eltigerchino eltigerchino commented Dec 18, 2023

fixes #11382

The implementation for ensuring the basepath root page always ends with a trailing slash in #10763 is wrong because it was implemented in the load_node method, causing the always trailing slash option to be set on all nodes the root page uses (such as the root layout node), and affecting pages other than the root page. This PR moves the logic closer to where we normalize the URL based on the trailing slash option so we only evaluate the correct trailing slash option after loading the nodes.

Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

  • It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.

Tests

  • Run the tests with pnpm test and lint the project with pnpm lint and pnpm check

Changesets

  • If your PR makes a change that should be noted in one or more packages' changelogs, generate a changeset by running pnpm changeset and following the prompts. Changesets that add features should be minor and those that fix bugs should be patch. Please prefix changeset messages with feat:, fix:, or chore:.

Copy link

changeset-bot bot commented Dec 18, 2023

🦋 Changeset detected

Latest commit: 7858b48

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@sveltejs/kit Patch

Not sure what this means? Click here to learn what changesets are.

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

@benmccann
Copy link
Member

It looks like the tests are failing

A note that it looks like #11357 fixed the server-side and this is fixing the client side

@eltigerchino
Copy link
Member Author

Tests are fixed now. Targeting the link by its href was a bad idea when there's the base path variable involved

@nikhil-swamix

This comment was marked as off-topic.

@eltigerchino

This comment was marked as off-topic.

@Rich-Harris Rich-Harris merged commit 9556aba into main Jan 9, 2024
13 checks passed
@Rich-Harris Rich-Harris deleted the fix-trailing-slash-for-real branch January 9, 2024 14:28
@github-actions github-actions bot mentioned this pull request Jan 9, 2024
@Coronon
Copy link

Coronon commented Jan 13, 2024

I just spent 1.5 hours debugging this and was about to submit my own PR when I saw this - thank you for all your work everyone!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
paths.base bugs relating to `config.kit.paths.base`
Projects
None yet
Development

Successfully merging this pull request may close these issues.

trailingSlash option not working correctly or consistently in SvelteKit 2
5 participants