@@ -14,7 +14,7 @@ def url2pathname(url):
1414 # ///C:/foo/bar/spam.foo
1515 # become
1616 # C:\foo\bar\spam.foo
17- import string , urllib .parse
17+ import urllib .parse
1818 if url [:3 ] == '///' :
1919 # URL has an empty authority section, so the path begins on the third
2020 # character.
@@ -25,19 +25,14 @@ def url2pathname(url):
2525 if url [:3 ] == '///' :
2626 # Skip past extra slash before UNC drive in URL path.
2727 url = url [1 :]
28- # Windows itself uses ":" even in URLs.
29- url = url .replace (':' , '|' )
30- if not '|' in url :
31- # No drive specifier, just convert slashes
32- # make sure not to convert quoted slashes :-)
33- return urllib .parse .unquote (url .replace ('/' , '\\ ' ))
34- comp = url .split ('|' )
35- if len (comp ) != 2 or comp [0 ][- 1 ] not in string .ascii_letters :
36- error = 'Bad URL: ' + url
37- raise OSError (error )
38- drive = comp [0 ][- 1 ]
39- tail = urllib .parse .unquote (comp [1 ].replace ('/' , '\\ ' ))
40- return drive + ':' + tail
28+ else :
29+ if url [:1 ] == '/' and url [2 :3 ] in ':|' :
30+ # Skip past extra slash before DOS drive in URL path.
31+ url = url [1 :]
32+ if url [1 :2 ] == '|' :
33+ # Older URLs use a pipe after a drive letter
34+ url = url .replace ('|' , ':' , 1 )
35+ return urllib .parse .unquote (url .replace ('/' , '\\ ' ))
4136
4237def pathname2url (p ):
4338 """OS-specific conversion from a file system path to a relative URL
0 commit comments