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

[Bug]: Cannot include a '?' character in a manually specified.... #9613

Closed
VQH-cmd opened this issue Nov 19, 2022 · 2 comments
Closed

[Bug]: Cannot include a '?' character in a manually specified.... #9613

VQH-cmd opened this issue Nov 19, 2022 · 2 comments
Labels

Comments

@VQH-cmd
Copy link

VQH-cmd commented Nov 19, 2022

What version of React Router are you using?

6.4.x

Steps to Reproduce

Cannot include a '?' character in a manually specified.... on Link / NavLink Container

It has been more than 1 month since 6.4 released, and the annoying issue still exists !
Even in 6.4.3 version recently !

6.4.x is very unstable.

Issue

Expected Behavior

<Link to="/somepath/?query=abcd">Target</Link>
<Route path="/somepath?query=:q" element={<Comp />} />

When ever ? appears in to or path => issue happen.

Actual Behavior

Link and NavLink if has ? character.

@VQH-cmd VQH-cmd added the bug label Nov 19, 2022
@VQH-cmd VQH-cmd changed the title [Bug]: [Bug]: Cannot include a '?' character in a manually specified.... Nov 19, 2022
@timdorr
Copy link
Member

timdorr commented Nov 19, 2022

You can't match a Route on the query string in the path. If this was possible in 6.3 or earlier, that was a bug. The query string is intentionally not supposed to match on a Route, as it is intended for extra data you want sent to that Route.

@timdorr timdorr closed this as completed Nov 19, 2022
@pganster
Copy link

I've gotten this error when using navigate() to navigate to an URL that includes query parameters. I'm receiving the URL from a third party service (the onRedirectCallback callback from auth0-react to be concrete).

Supplying a URL with a query parameter worked with 6.3, but after upgrading to 6.4.3 I'm receiving the same error as described in this issue.

To get the same behavior as before, instead of simply calling navigate({pathname: returnTo}), I'm currently supplying the URL from the third party service this way:

const returnToUrl = new URL(returnTo, window.location.origin);
navigate({
     pathname: returnToUrl.pathname,
     search: returnToUrl.searchParams.toString()
});

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

No branches or pull requests

3 participants