params argument on URL should merge, not replace. (#653)
This commit is contained in:
parent
5ee512d803
commit
74e5115b86
@ -90,9 +90,14 @@ class URL:
|
||||
if self.is_absolute_url:
|
||||
self._uri_reference = self._uri_reference.normalize()
|
||||
|
||||
# Add any query parameters.
|
||||
# Add any query parameters, merging with any in the URL if needed.
|
||||
if params:
|
||||
query_string = str(QueryParams(params))
|
||||
if self._uri_reference.query:
|
||||
url_params = QueryParams(self._uri_reference.query)
|
||||
url_params.update(params)
|
||||
query_string = str(url_params)
|
||||
else:
|
||||
query_string = str(QueryParams(params))
|
||||
self._uri_reference = self._uri_reference.copy_with(query=query_string)
|
||||
|
||||
# Enforce absolute URLs by default.
|
||||
|
||||
@ -89,7 +89,7 @@ def test_url_params():
|
||||
assert str(url) == "https://example.org:123/path/to/somewhere?a=123"
|
||||
|
||||
url = URL("https://example.org:123/path/to/somewhere?b=456", params={"a": "123"})
|
||||
assert str(url) == "https://example.org:123/path/to/somewhere?a=123"
|
||||
assert str(url) == "https://example.org:123/path/to/somewhere?b=456&a=123"
|
||||
|
||||
|
||||
def test_url_join():
|
||||
|
||||
Loading…
Reference in New Issue
Block a user