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

Normalize double slashes in incoming locations #11924

Open
wants to merge 1 commit into
base: v6
Choose a base branch
from

Conversation

brophdawg11
Copy link
Contributor

Closes #11911

Copy link

changeset-bot bot commented Aug 22, 2024

🦋 Changeset detected

Latest commit: 1b4bdf8

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

This PR includes changesets to release 5 packages
Name Type
@remix-run/router Patch
react-router Patch
react-router-dom Patch
react-router-dom-v5-compat Patch
react-router-native 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

Comment on lines +543 to +553
let toLocation = typeof to === "string" ? parsePath(to) : to;
if (toLocation.pathname) {
toLocation.pathname = normalizeMultipleSlashes(toLocation.pathname);
}
let location: Readonly<Location> = {
pathname: typeof current === "string" ? current : current.pathname,
pathname: normalizeMultipleSlashes(
typeof current === "string" ? current : current.pathname
),
search: "",
hash: "",
...(typeof to === "string" ? parsePath(to) : to),
...toLocation,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm curious if we think this is too widespread. There is a very targeted fix we could put in createURL that just fixes scenarios we expect would throw. By doing it here are a bit more robust and effectively sanitize when we create Location's for the router. We do then expose Location's back out to the user so it might be a concern of that feeling "breaking" to mess with incoming paths in a different manner...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: "TypeError: URL constructor: // is not a valid URL" while using data router
1 participant