Skip to content

Commit

Permalink
Merge branch 'main' into pythongh-127134
Browse files Browse the repository at this point in the history
  • Loading branch information
savannahostrowski authored Nov 22, 2024
2 parents 2a6ad4e + 8c98ed8 commit d71e70e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
3 changes: 3 additions & 0 deletions Lib/nturl2path.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ def url2pathname(url):
elif url[:12] == '//localhost/':
# Skip past 'localhost' authority.
url = url[11:]
if url[:3] == '///':
# Skip past extra slash before UNC drive in URL path.
url = url[1:]
# Windows itself uses ":" even in URLs.
url = url.replace(':', '|')
if not '|' in url:
Expand Down
2 changes: 1 addition & 1 deletion Lib/test/test_urllib.py
Original file line number Diff line number Diff line change
Expand Up @@ -1492,7 +1492,7 @@ def test_url2pathname_win(self):
# UNC paths
self.assertEqual(fn('//server/path/to/file'), '\\\\server\\path\\to\\file')
self.assertEqual(fn('////server/path/to/file'), '\\\\server\\path\\to\\file')
self.assertEqual(fn('/////server/path/to/file'), '\\\\\\server\\path\\to\\file')
self.assertEqual(fn('/////server/path/to/file'), '\\\\server\\path\\to\\file')
# Localhost paths
self.assertEqual(fn('//localhost/C:/path/to/file'), 'C:\\path\\to\\file')
self.assertEqual(fn('//localhost/C|/path/to/file'), 'C:\\path\\to\\file')
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fix issue where :func:`urllib.request.url2pathname` failed to discard an
extra slash before a UNC drive in the URL path on Windows.

0 comments on commit d71e70e

Please sign in to comment.