yarl icon indicating copy to clipboard operation
yarl copied to clipboard

Allow scheme replacement for relative urls

Open asvetlov opened this issue 6 years ago • 2 comments

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

asvetlov avatar Jan 10 '19 13:01 asvetlov

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

aio-libs-bot avatar Jan 10 '19 13:01 aio-libs-bot

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.

mjpieters avatar Mar 29 '22 09:03 mjpieters