Skip to content

Commit b5b50d4

Browse files
committed
Strip the third slash from file URIs on Windows
1 parent f0e5d6b commit b5b50d4

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

domdf_python_tools/paths.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
import json
4949
import os
5050
import pathlib
51+
import platform
5152
import shutil
5253
import stat
5354
import sys
@@ -851,7 +852,12 @@ def from_uri(cls: Type[_PP], uri: str) -> _PP:
851852
if parseresult.netloc or parseresult.params or parseresult.query or parseresult.fragment:
852853
raise ValueError("Malformed file URI")
853854

854-
return cls(urllib.parse.unquote_to_bytes(parseresult.path).decode("UTF-8"))
855+
path = urllib.parse.unquote_to_bytes(parseresult.path).decode("UTF-8")
856+
857+
if os.name == "nt":
858+
path = path.lstrip('/')
859+
860+
return cls(path)
855861

856862

857863
class PosixPathPlus(PathPlus, pathlib.PurePosixPath):

0 commit comments

Comments
 (0)