mirror of
https://github.com/hoppscotch/hoppscotch.git
synced 2026-04-26 01:06:00 +03:00
[GH-ISSUE #87] The query string is built incorrectly when the path contains a parameter #34
Labels
No labels
CodeDay
a11y
browser limited
bug
bug fix
cli
core
critical
design
desktop
discussion
docker
documentation
duplicate
enterprise
feature
feature
fosshack
future
good first issue
hacktoberfest
help wanted
i18n
invalid
major
minor
need information
need testing
not applicable to hoppscotch
not reproducible
pull-request
question
refactor
resolved
sandbox
self-host
spam
stale
testmu
wip
wont fix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/hoppscotch#34
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @simoncas on GitHub (Aug 28, 2019).
Original GitHub issue: https://github.com/hoppscotch/hoppscotch/issues/87
Originally assigned to: @simoncas, @hosseinnedaee on GitHub.
Describe the bug
The URL is crafted incorrectly when the path already contains a query string and when additional parameters are added through the options.
Example: https://reqres.in/api/users?param1=value1?param2=value2
To Reproduce
Steps to reproduce the behavior:
url: http://whatever.com
path: /whatever?param1=value1
parameters: param2 as Key1 and value2 as Value1
Open the developer tools and select the network tab. Filter requests by XHR
Send the request by hitting the Send button.
Using the developer tools, analyze the HTTP request crafted by postwoman, especially the URL
The URL is https://reqres.in/api/users?param1=value1?param2=value2 which isn't valid. The query string isn't valid since the parameters are preceded twice by a question mark. The second parameter should be preceded by a "&" instead.
Expected behavior
The crafted URL should be https://reqres.in/api/users?param1=value1¶m2=value2.
In other words, if the path already contains a query string then the additional parameters specified through the parameter section must be correctly added.
Screenshots

@liyasthomas commented on GitHub (Aug 29, 2019):
While we're finding a fix to this issue, I suggest you to separate parameters from request
pathand use Parameters section to specify required parameters.@simoncas commented on GitHub (Aug 29, 2019):
I'm okay to work on this.
They are 2 ways to solve this issue.
First option:
Check with a regex if the query string already contains parameters. Then based on the result, craft correctly the query string. (quick fix)
Second option:
Extract the parameters from the
pathand automatically fill the parameters sections with the params. (postman style). We must also decide if we should keep in sync (bidirectional) the parameters section and thepath. This is how it's implemented by postman. When a change is made whether to thepathor to the parameters sections then the change is replicated to the other component.(sounds more like a feature).
What do you think ?
@liyasthomas commented on GitHub (Aug 29, 2019):
Second option sounds great! I've assigned this to you. Looking forward on your PR 🙌
@liyasthomas commented on GitHub (Aug 29, 2019):
#62 can also be solved with the second approach of binding key-value pairs to a fast URL entry input box. @NBTX
@AndrewBastin commented on GitHub (Aug 30, 2019):
Yoo, I was kinda working on a PR myself for this... My idea to resolve this was on clicking the Send button, the path input is parsed and the values are appended to the params list.
@AndrewBastin commented on GitHub (Sep 12, 2019):
Hi there,
So, I am kinda busy as I am moving to Canada and won't be back on proper coding till like the end of the week, so in the meantime, I am unassigning myself from this issue, anyone interested to tackle this issue please feel to do so.
@hosseinnedaee commented on GitHub (Sep 13, 2019):
Hi,
Can I work on this?
I'd like to solve it with the second approach.
@liyasthomas commented on GitHub (Sep 13, 2019):
@hosseinnedaee you are open to work on this 🎉
@hosseinnedaee commented on GitHub (Sep 16, 2019):
Hi
I pushed my changes sync-path-and-parameters
Could you please check the functionality. (I didn't clean the code yet)
@liyasthomas commented on GitHub (Sep 16, 2019):
@hosseinnedaee I went through your approach. Seems to be working. Clean your code, optimize the logic. And send PR. I'll run few tests once again.
Btw, thanks for the quick response 🎉
@hosseinnedaee commented on GitHub (Sep 17, 2019):
@liyasthomas you're welcome
I have submitted a PR #152
@liyasthomas commented on GitHub (Sep 18, 2019):
#152 solves this issue hence closing
Copy ResponseButton #2378