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]: Unable to match a url that ends in an equal sign #11897

Closed
phazei opened this issue Aug 15, 2024 · 1 comment
Closed

[Bug]: Unable to match a url that ends in an equal sign #11897

phazei opened this issue Aug 15, 2024 · 1 comment
Labels

Comments

@phazei
Copy link

phazei commented Aug 15, 2024

What version of React Router are you using?

6.26

Steps to Reproduce

We just converted our entire site over to react-router v6 and just realized one route isn't working. We're using createHashRouter.

{ path: '/access_token=:params', name: 'SSO Access Token', element: <SSOAccessToken /> }

It's an irregular url because it's directed to us from an old system and we can't adjust the path, all the component does is stores the param and redirects elsewhere.

It's fine if we need to parse the url for the params ourselves, but we can't even get that far.

If I set path to path: '/access_token=' then it will load the page, but only that exact url. I tried path: '/access_token=*' and it ignores that splat. Is there any way we can get '/access_token*' to load? Are we doing something wrong?

Expected Behavior

when I set the path to /access_token* I expect it to match like a wild card.

Actual Behavior

It gives me a 404

@phazei phazei added the bug label Aug 15, 2024
@brophdawg11
Copy link
Contributor

Partial dynamic param/splat segments are not supported - at one point partial dynamic segments worked inadvertently but that was fixed in 6.5.0. The param has to be the full URL segment.

You should use a dynamic param or splat route and you can look for access_token=... in the param manually:

let routes = [{ path: '/:param', element: <Param> }];

function Param() {
  let params = useParams();
  if (params.param.startsWith('access_token=')) {
    return <SSOAccessToken />; // or redirect
  }

  // ...
}

@brophdawg11 brophdawg11 closed this as not planned Won't fix, can't repro, duplicate, stale Aug 16, 2024
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

2 participants