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

GH-126766: url2pathname(): handle 'localhost' authority #127129

Merged
merged 2 commits into from
Nov 22, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Align Windows and POSIX implementations a little more.
  • Loading branch information
barneygale committed Nov 22, 2024
commit fb5e8af06b581bfa622dcf81fb39b65631d4032e
14 changes: 7 additions & 7 deletions Lib/nturl2path.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@ def url2pathname(url):
# become
# C:\foo\bar\spam.foo
import string, urllib.parse
if url[:3] == '///':
# URL has an empty authority section, so the path begins on the third
# character.
url = url[2:]
elif url[:12] == '//localhost/':
# Skip past 'localhost' authority.
url = url[11:]
# Windows itself uses ":" even in URLs.
url = url.replace(':', '|')
if not '|' in url:
# No drive specifier, just convert slashes
if url[:3] == '///':
# URL has an empty authority section, so the path begins on the
# third character.
url = url[2:]
elif url[:12] == '//localhost/':
# Skip past 'localhost' authority.
url = url[11:]
# make sure not to convert quoted slashes :-)
return urllib.parse.unquote(url.replace('/', '\\'))
comp = url.split('|')
Expand Down
Loading