-
-
Notifications
You must be signed in to change notification settings - Fork 169
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve handling empty segments in urls according to RFC3986
The patch makes `yarl.URL()` objects preserve empty segments when joining additional parts in cases like ```python URL("https://web.archive.org/web/") / "https://github.com/" ``` PR #1026 Fixes #926 Fixes #984 Closes #1023 Co-authored-by: Sam Bull <[email protected]> Co-authored-by: Sviatoslav Sydorenko <[email protected]> Co-authored-by: Alessio Bogon <[email protected]>
- Loading branch information
1 parent
433beaf
commit 4bededd
Showing
6 changed files
with
110 additions
and
22 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
Joining URLs with empty segments has been changed | ||
to match :rfc:`3986`. | ||
|
||
Previously empty segments would be removed from path, | ||
breaking use-cases such as | ||
|
||
.. code-block:: python | ||
URL("https://web.archive.org/web/") / "https://github.com/" | ||
Now :meth:`/ operation <yarl.URL.__truediv__>` and :meth:`URL.joinpath() <yarl.URL.joinpath>` | ||
keep empty segments, but do not introduce new empty segments. | ||
e.g. | ||
|
||
.. code-block:: python | ||
URL("https://example.org/") / "" | ||
does not introduce an empty segment. | ||
|
||
-- by :user:`commonism` and :user:`youtux` |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
The pre-existing :meth:`/ magic method <yarl.URL.__truediv__>` | ||
has been documented in the API reference -- by :user:`commonism`. |
This file contains 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
This file contains 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
This file contains 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