-
-
Notifications
You must be signed in to change notification settings - Fork 170
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
RFC3986 compatible URL.join honoring empty segments (#1039)
Co-authored-by: Sviatoslav Sydorenko (Святослав Сидоренко) <[email protected]> Co-authored-by: J. Nick Koston <[email protected]> Co-authored-by: Sam Bull <[email protected]>
- Loading branch information
1 parent
84e1c7d
commit e3dd736
Showing
3 changed files
with
148 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
:meth:`URL.join() <yarl.URL.join>` has been changed to match | ||
:rfc:`3986` and align with | ||
:meth:`/ operation <yarl.URL.__truediv__>` and :meth:`URL.joinpath() <yarl.URL.joinpath>` | ||
when joining URLs with empty segments. | ||
Previously :py:func:`urllib.parse.urljoin` was used, | ||
which has known issues with empty segments | ||
(`python/cpython#84774 <https://github.com/python/cpython/issues/84774>`_). | ||
|
||
Due to the semantics of :meth:`URL.join() <yarl.URL.join>`, joining an | ||
URL with scheme requires making it relative, prefixing with ``./``. | ||
|
||
.. code-block:: pycon | ||
>>> URL("https://web.archive.org/web/").join(URL("./https://github.com/aio-libs/yarl")) | ||
URL('https://web.archive.org/web/https://github.com/aio-libs/yarl') | ||
Empty segments are honored in the base as well as the joined part. | ||
|
||
.. code-block:: pycon | ||
>>> URL("https://web.archive.org/web/https://").join(URL("github.com/aio-libs/yarl")) | ||
URL('https://web.archive.org/web/https://github.com/aio-libs/yarl') | ||
-- 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