gruns / furl

🌐 URL parsing and manipulation made easy.
Other
2.64k stars 153 forks source link

Rootless file URIs do not round trip #115

Open timj opened 5 years ago

timj commented 5 years ago

RFC-3986 talks about rootless path URIs. I interpret this to mean that a URI of file:relative/path.ext is a perfectly reasonably URI indicating a relative path. Unfortunately this does not round trip:

>>> from furl import furl
>>> f = furl("file:relative/path.ext")
>>> f
furl('file:///relative/path.ext')
>>> f.path
Path('relative/path.ext')
>>> f2 = furl("file:///relative/path.ext")
>>> f2.path
Path('/relative/path.ext')
>>> f2
furl('file:///relative/path.ext')

The URI is turned from a relative path to an absolute path. In the first instance internally the object knows that it is a relative path but the stringification of the URL turns it into an absolute path.

timj commented 5 years ago

I've been pointed at RFC8089 which clarifies the behavior of file scheme URLs, overriding RFC3986, so I'm closing this as not a bug. Would it be possible to issue a warning though?

See related discussion in marrow/uri#11

amcgregor commented 5 years ago

Additional discussion in marrow/uri#9 with indirect feedback from, apparently, an author of the RFC.