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(5457): normalize path on prefetch #5458

Merged
merged 5 commits into from
Jul 11, 2022
Merged

Conversation

GauBen
Copy link
Contributor

@GauBen GauBen commented Jul 10, 2022

Fixes #5457

@changeset-bot
Copy link

changeset-bot bot commented Jul 10, 2022

🦋 Changeset detected

Latest commit: 29a7196

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

@GauBen
Copy link
Contributor Author

GauBen commented Jul 11, 2022

I have no idea what's happening but this is fun to watch.

As a sidenote, I was thinking about normalizing before matching:

const path = decodeURI(url.pathname.slice(base.length) || '/');
const normalized_path = normalize_path(url.pathname, trailing_slash);

for (const route of routes) {
	  const params = route.exec(normalized_path);
	  
	  if (params) {
		  const id = normalized_path + url.search;
		  /** @type {import('./types').NavigationIntent} */
		  const intent = { id, route, params, url };
		  return intent;
	  }
}

It may solve current and future issues, or may not, I have no idea.

@Rich-Harris
Copy link
Member

Thanks!

I was thinking about normalizing before matching:

I don't think there's any benefit to doing so — it's the same amount of work in either case

@Rich-Harris Rich-Harris merged commit d22fbcb into sveltejs:master Jul 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Prefetch and trailingSlash: 'always'
2 participants