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 4848import json
4949import os
5050import pathlib
51- import platform
5251import shutil
5352import stat
5453import sys
@@ -849,13 +848,25 @@ def from_uri(cls: Type[_PP], uri: str) -> _PP:
849848
850849 if parseresult .scheme != "file" :
851850 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 :
853852 raise ValueError ("Malformed file URI" )
854853
855- path = urllib . parse . unquote_to_bytes ( parseresult . path ). decode ( "UTF-8" )
854+ if sys . platform == "win32" :
856855
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" )
859870
860871 return cls (path )
861872
You can’t perform that action at this time.
0 commit comments