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

Open
asvetlov opened this issue Jan 10, 2019 · 2 comments
Open

Allow scheme replacement for relative urls #280

asvetlov opened this issue Jan 10, 2019 · 2 comments

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:https:///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.

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

No branches or pull requests

3 participants