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]: Link to and useParam decode %25 only #7987

Closed
EthanSchoen opened this issue Sep 1, 2021 · 5 comments
Closed

[Bug]: Link to and useParam decode %25 only #7987

EthanSchoen opened this issue Sep 1, 2021 · 5 comments

Comments

@EthanSchoen
Copy link

What version of React Router are you using?

5.2.1

Steps to Reproduce

Here is the sandbox

You can click the links provided and see the url is decoded for %25 but not %24.
Also if you type the url path of %25 the value of the param is just "%" but is "%24" for %24

Expected Behavior

I expected %25 not to be decoded like all other encoded special characters

Actual Behavior

%25 is the only special character code that is decoded while other special character codes are not decoded.

@EthanSchoen
Copy link
Author

EthanSchoen commented Sep 1, 2021

After thinking about it some more, I think remix-run/history#505 might apply here so then this wouldn't be an issue (for link to at least)

however because of this issue: #7173 (comment)
I thought for the case when you type %25 in the url and useParam wouldn't decode the %25 but that might be the same issue.

@CruseCtrl
Copy link

I've got the same issue. I want the url of an item to be (an encoded version of) its name, so I've got

<Link to={`/item/${encodeURIComponent(item.name)}`>{item.name}</Link>

And I'm trying to retrieve the item name on the item page.

I've got

<Router>
  <Switch>
    <Route path='/item/:itemName'>
      <ViewItem />
    </Route
  </Switch
</Router>

And in the ViewItem page

const { itemName } = useParams();

But if the item name is ?% then the link correctly goes to /item/%2F%25 but itemName ends up being %2F%, which I can't pass to decodeURIComponent without it throwing an error.

How can I link to an arbitrary item name, and retrieve the correct name from the URL on the view item page?

@github-actions
Copy link
Contributor

This issue has been automatically marked stale because we haven't received a response from the original author in a while 🙈. This automation helps keep the issue tracker clean from issues that are not actionable. Please reach out if you have more information for us or you think this issue shouldn't be closed! 🙂 If you don't do so within 7 days, this issue will be automatically closed.

@github-actions
Copy link
Contributor

github-actions bot commented May 5, 2023

This issue has been automatically closed because we haven't received a response from the original author 🙈. This automation helps keep the issue tracker clean from issues that aren't actionable. Please reach out if you have more information for us! 🙂

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale May 5, 2023
@shabbir-dhangot
Copy link

We are experiencing a similar issue where a parameter is automatically converting "%25" into "%".

Here is the use case:

  • We need to pass "startData%253A" as an argument.
  • After encode it, we send it as "startData%25253A".
  • The URL we send looks like this: "https://abc.com/startData%25253A".

However, when receiving the "useParams", it automatically converts "%25" to "%". As a result, the received parameter is already decoded, and when we decode it again, it changes to "%3A". This causes a failure in our API logic.

It appears that this issue was closed without any resolution. We kindly request your assistance in addressing this matter.

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

No branches or pull requests

3 participants