fix(client): ensure encoded query params are never duplicated #2219
Merged
max-wittig merged 2 commits intomainfrom Aug 4, 2022
Merged
fix(client): ensure encoded query params are never duplicated #2219max-wittig merged 2 commits intomainfrom
max-wittig merged 2 commits intomainfrom
Conversation
| params = parse.parse_qs(parsed.query) | ||
| utils.copy_dict(src=query_data, dest=params) | ||
|
|
||
| url = raw_url.replace(parsed.query, "").strip("?") |
Member
There was a problem hiding this comment.
Why not use parse.urlunparse?
url = parse.urlunparse(parsed._replace(query=""))
Member
Author
There was a problem hiding this comment.
I saw that on stackoverflow as well but it uses a private method (_replace) so didn't want to touch that 😁
Member
There was a problem hiding this comment.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
nextheader links, so I think this will also make other things more robust in the future).