-
-
Notifications
You must be signed in to change notification settings - Fork 168
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
Handling of relative path URL #648
Comments
Agree with the second suggestion: |
>>> URL("file:///foo/bar").is_absolute()
False python discussion about parsing relative path URL: https://bugs.python.org/issue40938 |
It is, but >>> URL("file:foo/bar")
URL('file:///foo/bar')
>>> URL("file:foo/bar").is_absolute()
False The point is that even though it is not absolute, the representation of the object makes it look like it is. |
@mjpieters |
This is really a >>> from urllib.parse import urlsplit
>>> urlsplit('file:foo/bar')
SplitResult(scheme='file', netloc='', path='foo/bar', query='', fragment='')
>>> urlsplit('file:foo/bar').geturl()
'file:///foo/bar'
>>> urlsplit('file:///foo/bar')
SplitResult(scheme='file', netloc='', path='/foo/bar', query='', fragment='')
>>> urlsplit('file:///foo/bar').geturl()
'file:///foo/bar' This applies to all schemes in the >>> urlsplit('http:foo/bar').geturl()
'http:///foo/bar'
>>> urlsplit('custom:foo/bar').geturl()
'custom:foo/bar' I'm not 100% certain this is fixable; having a netloc requires that the path is absolute. The better solution is to not accept such URLs, basically. @asvetlov Can't we deprecate the 'feature'? |
|
If this is something the yarl does want to address, then you should call >>> urlunsplit(('', '', 'foo/bar', '', ''))
'foo/bar' Do this only if the path doesn't start with Alternatively, start deprecation now, and detect problematic URLs by checking for schemes in |
Describe the bug
According to rfc 8089 paths for file URIs are absolute.
yarl.URL
does not complain about them but displays a wrong repr.To Reproduce
Expected behavior
yarl.URL('file:foo/bar')
should raise exception or produce instance with correct repr:assert repr(URL('file:foo/bar')) == 'file:foo/bar'
Logs/tracebacks
multidict Version
yarl Version
OS
NixOS
Additional context
No response
Code of Conduct
The text was updated successfully, but these errors were encountered: