fix file: URL parsing for windows

Linux: /abs/path -> file:///abs/path
Windows: c:/abs/path -> file:///c:/abs/path
This commit is contained in:
Thomas Waldmann 2026-01-27 17:20:34 +01:00
parent 0f0566ea63
commit 9eaf7df3f0
No known key found for this signature in database
GPG key ID: 243ACFA951F78E01

View file

@ -18,6 +18,7 @@ from functools import partial
from string import Formatter
from ..logger import create_logger
from ..platformflags import is_win32
logger = create_logger()
@ -453,8 +454,8 @@ class Location:
(?P<path>.+)
"""
# abs_path must start with a slash.
abs_path_re = r"(?P<path>/.+)"
# abs_path must start with a slash (or drive letter on Windows).
abs_path_re = r"(?P<path>[A-Za-z]:/.+)" if is_win32 else r"(?P<path>/.+)"
# path may or may not start with a slash.
abs_or_rel_path_re = r"(?P<path>.+)"
@ -493,7 +494,8 @@ class Location:
rclone_re = re.compile(r"(?P<proto>rclone):(?P<path>(.*))", re.VERBOSE)
file_or_socket_re = re.compile(r"(?P<proto>(file|socket))://" + abs_path_re, re.VERBOSE)
sl = "/" if is_win32 else ""
file_or_socket_re = re.compile(r"(?P<proto>(file|socket))://" + sl + abs_path_re, re.VERBOSE)
local_re = re.compile(local_path_re, re.VERBOSE)