Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Fix gh-1934: Search bar special chars #2075
The text was encoded once already by the search bar. That means we need to decode it twice in order to decode special characters.
?q=cat%3Fcat (should now appear as cat?cat)
This is awesome!
Using your code change, when I put ?q=cat%20cat into the search box and press enter, it does indeed convert the %20 to a space. However, it does not actually do anything about the ?q= part -- so the result is "?q=cat cat". I still need to click on the Studios button/tab to get it to be "cat cat".
(I'm trying the replication instructions in #1934, FYI.)
Here's what I think will fix it. We need to repeat the entire set of steps that strip the search syntax away, not just the decodeURIComponent function. So we can make a function like
that we can call from componentDidMount twice, like
This should make the string resolve completely, the first time:
The 'key' parameter allows us to use this for handling the mode query key-value in the constructor as well, like:
Want to try that, or something like it, and test further?
Oh, I think I misinterpreted the bug report.
Sorry for the delay, @chen-robert! This looks good to me, and I tested it and it works great.
I think I misinterpreted the bug report too -- and the gif there was a bit confusing. You're right, we shouldn't really be worrying about users actually manually entering "?q=cat%20cat" into the search box!
Thanks for this!