- Notifications
You must be signed in to change notification settings - Fork673
fix(client): ensure encoded query params are never duplicated#2219
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
utils.copy_dict(src=query_data, dest=params) | ||
url = raw_url.replace(parsed.query, "").strip("?") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Why not useparse.urlunparse
?
url = parse.urlunparse(parsed._replace(query=""))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I saw that on stackoverflow as well but it uses a private method (_replace
) so didn't want to touch that 😁
JohnVillalovosAug 4, 2022 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Oh it is documented in the official docs:
https://docs.python.org/3/library/urllib.parse.html
As is the case with all named tuples, the subclass has a few additional methods and attributes that are particularly useful. One such method is _replace(). The _replace() method will return a new ParseResult object replacing specified fields with new values.
Uh oh!
There was an error while loading.Please reload this page.
Closes#2218
This provides a small generic fix at the http_request level instead of messing even more with our own flows.
(I've always thought it was a bit weird that GitLab returns a lot of boilerplate query params in ther
next
header links, so I think this will also make other things more robust in the future).