diff --git a/amplifier_foundation/paths/resolution.py b/amplifier_foundation/paths/resolution.py index 92e88ccf..72027aa6 100644 --- a/amplifier_foundation/paths/resolution.py +++ b/amplifier_foundation/paths/resolution.py @@ -128,6 +128,10 @@ def parse_uri(uri: str) -> ParsedURI: path, subpath = _extract_fragment_subpath(uri[7:]) return ParsedURI(scheme="file", host="", path=path, ref="", subpath=subpath) + # Handle Windows absolute paths + if re.match(r"^[A-Za-z]:[\\/]", uri) or uri.startswith("\\\\"): + return ParsedURI(scheme="file", host="", path=uri, ref="", subpath="") + # Handle absolute paths if uri.startswith("/"): return ParsedURI(scheme="file", host="", path=uri, ref="", subpath="") diff --git a/tests/test_paths.py b/tests/test_paths.py index ae9a059b..cdeb1c54 100644 --- a/tests/test_paths.py +++ b/tests/test_paths.py @@ -116,6 +116,20 @@ def test_file_uri(self) -> None: assert result.scheme == "file" assert result.path == "/home/user/bundle" + def test_parse_windows_absolute_path(self) -> None: + """Parses Windows absolute paths as file URIs.""" + result = parse_uri(r"C:\Users\test\.amplifier\cache\module") + assert result.scheme == "file" + assert result.path == r"C:\Users\test\.amplifier\cache\module" + assert result.host == "" + assert result.subpath == "" + + def test_parse_windows_unc_path(self) -> None: + """Parses Windows UNC paths as file URIs.""" + result = parse_uri(r"\\server\share\module") + assert result.scheme == "file" + assert result.path == r"\\server\share\module" + def test_https_uri(self) -> None: """Parses https:// URIs.""" result = parse_uri("https://example.com/bundle.yaml")