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

Allow scheme replacement for relative urls #280

Closed
asvetlov opened this issue Jan 10, 2019 · 3 comments · Fixed by #1138
Closed

Allow scheme replacement for relative urls #280

asvetlov opened this issue Jan 10, 2019 · 3 comments · Fixed by #1138

Comments

@asvetlov
Copy link
Member

URL('path/to').with_scheme('http') should work.
Now it produces scheme replacement is not allowed for relative URLs

@aio-libs-bot
Copy link

GitMate.io thinks possibly related issues are #185 (Allow joining URL and pathlib.Path), #99 (Document-relative urls like '?a=b'), #33 (Parse URL parameter), #272 (bool(URL()) should be False), and #24 (TypeError in URL.with_query).

@mjpieters
Copy link
Contributor

mjpieters commented Mar 29, 2022

File URLs that are absolute are also being blocked from updating the scheme:

>>> URL('file:///absolute/path').with_scheme('file')
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/.../lib/python3.7/site-packages/yarl/_url.py()", line 794, in with_scheme
    raise ValueError("scheme replacement is not allowed for relative URLs")
ValueError: scheme replacement is not allowed for relative URLs

This is rather a confusing error.

@bdraco
Copy link
Member

bdraco commented Sep 9, 2024

The http case is correct because the host is not allowed to be undefined for host see #821

The file case isn't correct though

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