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

[v6] [Bug]: URI encoded params sometimes fail to match in <Routes> #8109

Closed
thedanwoods opened this issue Oct 5, 2021 · 1 comment
Closed

Comments

@thedanwoods
Copy link

What version of React Router are you using?

6.0.0-beta.5

Steps to Reproduce

In some circumstances <Routes> or useRoutes is not matching deeper routes when the params are URI encoded.

This seems to be caused by a bug in the new getPathnameStart function. It's using the length of the params to work out where to trim the pathname. But params has already been URI decoded, whereas the pathname has not, so the .length is not reliable.

Repro at https://codesandbox.io/s/happy-villani-nee76?file=/src/App.js. Click on the "Item with id of ::" link and it doesn't render. If you downgrade to 6.0.0-beta.4 it works as expected.

Expected Behavior

In the codesandbox, /items/abc/%3A%3A should render the <SingleItem /> component.

Actual Behavior

It matches /items/abc/%3A and /items/abc/hi, but not /items/abc/%3A%3A.

@mjackson
Copy link
Member

mjackson commented Oct 5, 2021

Thanks for the report. I'm pretty sure this is a duplicate of #8072, which I'm working on fixing this week. Should be fixed in the next beta release.

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

No branches or pull requests

2 participants