RFC8089-compliant file URI support in urllib.request
#125866
Labels
type-feature
A feature request or enhancement
urllib.request
#125866
Feature or enhancement
I request that we make
pathname2url
andurl2pathname
parse and generate rfc8089-compliant file URIs. In particular, this means:pathname2url()
should return a URL with a non-empty authority when given a UNC pathpathname2url('//server/share')
->//server/share
rather than////server/share
url2pathname()
should ignore a 'localhost' authorityurl2pathname('//localhost/c:/foo')
->c:/foo
pathname2url()
should return a URL with a zero-length authority when given an absolute pathpathname2url('/etc/hosts')
->///etc/hosts
rather than/etc/hosts
url2pathname()
should ignore any empty or local authorityurl2pathname('///etc/hosts')
->/etc/hosts
rather than///etc/hosts
url2pathname('//127.0.0.1/etc/hosts
) ->/etc/hosts
.I further request that:
pathname2url()
is made to accept an optional include_scheme argument that sticksfile:
on the front when trueurl2pathname()
is made to strip anyfile:
prefix from its argument.I think this would go a long way towards making these functions usable, and allow us to remove the scary "This does not accept/produce a complete URL" warnings from the docs.
The text was updated successfully, but these errors were encountered: