Skip to content

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

Closed

Description

@VQH-cmd

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.

Activity

  1. changed the title [-][Bug]: [/-] [+][Bug]: Cannot include a '?' character in a manually specified....[/+] on Nov 19, 2022
  2. timdorr commented on Nov 19, 2022

    @timdorr
    Member

    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.

  3. pganster commented on Nov 28, 2022

    @pganster

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions