Skip to content

Commit b354a9e

Browse files
authored
Add files via upload
1 parent 3eea708 commit b354a9e

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

pycatfile.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -869,7 +869,11 @@ def RemoveWindowsPath(dpath):
869869
"""
870870
if not dpath:
871871
return ""
872-
if(re.findall("^file:/{2,3}", dpath)):
872+
if re.match("^file://", dpath, re.IGNORECASE):
873+
# Normalize to file:/// if it's a local path (no host)
874+
if dpath.lower().startswith("file://") and not dpath.lower().startswith("file:///"):
875+
# insert the extra slash
876+
dpath = "file:///" + dpath[7:]
873877
dparsed = urlparse(dpath)
874878
dpath = url2pathname(dparsed.path)
875879
# Accept bytes and decode safely
@@ -887,7 +891,11 @@ def NormalizeRelativePath(inpath):
887891
"""
888892
Ensures the path is relative unless it is absolute. Prepares consistent relative paths.
889893
"""
890-
if(re.findall("^file:/{2,3}", inpath)):
894+
if re.match("^file://", inpath, re.IGNORECASE):
895+
# Normalize to file:/// if it's a local path (no host)
896+
if inpath.lower().startswith("file://") and not inpath.lower().startswith("file:///"):
897+
# insert the extra slash
898+
inpath = "file:///" + inpath[7:]
891899
dparsed = urlparse(inpath)
892900
inpath = url2pathname(dparsed.path)
893901
inpath = RemoveWindowsPath(inpath)

0 commit comments

Comments
 (0)