Skip to content

Commit e3c495a

Browse files
committed
Patch copy_with
1 parent b07fe7b commit e3c495a

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

httpx/_urls.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,11 @@ def copy_with(self, **kwargs: typing.Any) -> "URL":
484484
# \_/ \______________/\_________/ \_________/ \__/
485485
# | | | | |
486486
# scheme authority path query fragment
487-
return URL(self._uri_reference.copy_with(**kwargs).unsplit())
487+
new_url = URL(self)
488+
new_url._uri_reference = self._uri_reference.copy_with(**kwargs)
489+
if new_url.is_absolute_url:
490+
new_url._uri_reference = new_url._uri_reference.normalize()
491+
return URL(new_url)
488492

489493
def copy_set_param(self, key: str, value: typing.Any = None) -> "URL":
490494
return self.copy_with(params=self.params.set(key, value))

0 commit comments

Comments
 (0)