File tree Expand file tree Collapse file tree 1 file changed +16
-5
lines changed Expand file tree Collapse file tree 1 file changed +16
-5
lines changed Original file line number Diff line number Diff line change 48
48
import json
49
49
import os
50
50
import pathlib
51
- import platform
52
51
import shutil
53
52
import stat
54
53
import sys
@@ -849,13 +848,25 @@ def from_uri(cls: Type[_PP], uri: str) -> _PP:
849
848
850
849
if parseresult .scheme != "file" :
851
850
raise ValueError (f"Unsupported URI scheme { parseresult .scheme !r} " )
852
- if parseresult .netloc or parseresult . params or parseresult .query or parseresult .fragment :
851
+ if parseresult .params or parseresult .query or parseresult .fragment :
853
852
raise ValueError ("Malformed file URI" )
854
853
855
- path = urllib . parse . unquote_to_bytes ( parseresult . path ). decode ( "UTF-8" )
854
+ if sys . platform == "win32" :
856
855
857
- if os .name == "nt" :
858
- path = path .lstrip ('/' )
856
+ if parseresult .netloc :
857
+ path = '' .join ([
858
+ "//" ,
859
+ urllib .parse .unquote_to_bytes (parseresult .netloc ).decode ("UTF-8" ),
860
+ urllib .parse .unquote_to_bytes (parseresult .path ).decode ("UTF-8" ),
861
+ ])
862
+ else :
863
+ path = urllib .parse .unquote_to_bytes (parseresult .path ).decode ("UTF-8" ).lstrip ('/' )
864
+
865
+ else :
866
+ if parseresult .netloc :
867
+ raise ValueError ("Malformed file URI" )
868
+
869
+ path = urllib .parse .unquote_to_bytes (parseresult .path ).decode ("UTF-8" )
859
870
860
871
return cls (path )
861
872
You can’t perform that action at this time.
0 commit comments