Skip to content

Commit 74eef4d

Browse files
authored
Add files via upload
1 parent 4e7c501 commit 74eef4d

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

pyarchivefile.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -856,7 +856,11 @@ def RemoveWindowsPath(dpath):
856856
"""
857857
if not dpath:
858858
return ""
859-
if(re.findall("^file:/{2,3}", dpath)):
859+
if re.match("^file://", dpath, re.IGNORECASE):
860+
# Normalize to file:/// if it's a local path (no host)
861+
if dpath.lower().startswith("file://") and not dpath.lower().startswith("file:///"):
862+
# insert the extra slash
863+
dpath = "file:///" + dpath[7:]
860864
dparsed = urlparse(dpath)
861865
dpath = url2pathname(dparsed.path)
862866
# Accept bytes and decode safely
@@ -874,7 +878,11 @@ def NormalizeRelativePath(inpath):
874878
"""
875879
Ensures the path is relative unless it is absolute. Prepares consistent relative paths.
876880
"""
877-
if(re.findall("^file:/{2,3}", inpath)):
881+
if re.match("^file://", inpath, re.IGNORECASE):
882+
# Normalize to file:/// if it's a local path (no host)
883+
if inpath.lower().startswith("file://") and not inpath.lower().startswith("file:///"):
884+
# insert the extra slash
885+
inpath = "file:///" + inpath[7:]
878886
dparsed = urlparse(inpath)
879887
inpath = url2pathname(dparsed.path)
880888
inpath = RemoveWindowsPath(inpath)

0 commit comments

Comments
 (0)