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

RFC8089-compliant file URI support in urllib.request #125866

Open
barneygale opened this issue Oct 23, 2024 · 0 comments
Open

RFC8089-compliant file URI support in urllib.request #125866

barneygale opened this issue Oct 23, 2024 · 0 comments
Labels
type-feature A feature request or enhancement

Comments

@barneygale
Copy link
Contributor

barneygale commented Oct 23, 2024

Feature or enhancement

I request that we make pathname2url and url2pathname parse and generate rfc8089-compliant file URIs. In particular, this means:

  • On Windows:
    • pathname2url() should return a URL with a non-empty authority when given a UNC path
      • e.g. pathname2url('//server/share') -> //server/share rather than ////server/share
    • url2pathname() should ignore a 'localhost' authority
      • e.g. url2pathname('//localhost/c:/foo') -> c:/foo
  • On POSIX:
    • pathname2url() should return a URL with a zero-length authority when given an absolute path
      • e.g. pathname2url('/etc/hosts') -> ///etc/hosts rather than /etc/hosts
    • url2pathname() should ignore any empty or local authority
      • e.g. url2pathname('///etc/hosts') -> /etc/hosts rather than ///etc/hosts
      • e.g. url2pathname('//127.0.0.1/etc/hosts) -> /etc/hosts.

I further request that:

  • pathname2url() is made to accept an optional include_scheme argument that sticks file: on the front when true
  • url2pathname() is made to strip any file: 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.

@barneygale barneygale added the type-feature A feature request or enhancement label Oct 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

1 participant