Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regression: Trailing slash for yarl.URL ("http://localhost") / "path" / "" is dropped in 1.9.4 #984

Closed
1 task done
alex-kowalczyk opened this issue Jan 22, 2024 · 4 comments · Fixed by #1026
Closed
1 task done
Labels

Comments

@alex-kowalczyk
Copy link

alex-kowalczyk commented Jan 22, 2024

Describe the bug

yarl 1.8.2 allowed to construct URLs with trailing slashes like that:

>>> str(yarl.URL ("http://localhost") / "path" / "") 
'http://localhost/path/'

yarl 1.9.4 drops the slash from that path. Possibly related to #862 :

>>> str(yarl.URL ("http://localhost") / "path" / "") 
'http://localhost/path'

To Reproduce

Try 1.8.2 vs 1.9.4 with the code above.

Expected behavior

Preserve the slash

Logs/tracebacks

-

Python Version

Python 3.11.6

multidict Version

$ python -m pip show multidict
Name: multidict
Version: 6.0.4
Summary: multidict implementation
Home-page: https://github.com/aio-libs/multidict
Author: Andrew Svetlov
Author-email: [email protected]
License: Apache 2
Requires: 
Required-by: aiohttp, yarl

yarl Version

$ python -m pip show yarl
Name: yarl
Version: 1.9.4
Summary: Yet another URL library
Home-page: https://github.com/aio-libs/yarl
Author: Andrew Svetlov
Author-email: [email protected]
License: Apache-2.0
Location: /home/alex/.local/share/virtualenvs/widget.backend-6HfWXuQ_/lib/python3.11/site-packages
Requires: idna, multidict
Required-by: aiohttp

OS

Ubuntu 23.10

Additional context

No response

Code of Conduct

  • I agree to follow the aio-libs Code of Conduct
@youtux
Copy link
Contributor

youtux commented Jun 5, 2024

This is actually a regression of version 1.9.1.

Please guys fix this, or at least document it in the changelog as it's quite a breaking change!

@webknjaz
Copy link
Member

webknjaz commented Jun 5, 2024

Feel free to send a PR with regression tests and possibly fixes. I don't think I'll have time to work on this myself.

cc @mjpieters @Dreamsorcerer

@youtux
Copy link
Contributor

youtux commented Jun 9, 2024

Done: #1023

webknjaz added a commit that referenced this issue Jul 3, 2024
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]>
@oleg-golovanov
Copy link

Hey guys, could you release a new version with this fix?

@webknjaz @Dreamsorcerer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
4 participants