-
-
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.
RFC3986 compatible URL.join honoring empty segments again (#1082)
Co-authored-by: Sviatoslav Sydorenko (Святослав Сидоренко) <wk.cvs.github@sydorenko.org.ua> Co-authored-by: J. Nick Koston <nick@koston.org> Co-authored-by: Sam Bull <aa6bs0@sambull.org> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
- Loading branch information
1 parent
b631867
commit af585b2
Showing
4 changed files
with
166 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 @@ | ||
1082.bugfix.rst |
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,29 @@ | ||
: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 change initially appeared in 1.9.5 but was reverted in 1.9.6 to resolve a problem with query string handling. |
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