Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions amplifier_foundation/paths/resolution.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ def parse_uri(uri: str) -> ParsedURI:
- zip+file:///local/archive.zip#subdirectory=path/inside
- file:///path/to/file
- /absolute/path
- C:\absolute\path or C:/absolute/path (Windows)
- \\server\share\path (Windows UNC)
- ./relative/path
- package-name
- package/subpath
Expand Down Expand Up @@ -136,6 +138,13 @@ def parse_uri(uri: str) -> ParsedURI:
if uri.startswith("./") or uri.startswith("../"):
return ParsedURI(scheme="file", host="", path=uri, ref="", subpath="")

# Handle Windows absolute paths (drive-letter or UNC)
is_drive_path = (
len(uri) >= 3 and uri[0].isalpha() and uri[1] == ":" and uri[2] in "/\\"
)
if is_drive_path or uri.startswith("\\\\"):
return ParsedURI(scheme="file", host="", path=uri, ref="", subpath="")

# Handle http/https URLs
if uri.startswith("http://") or uri.startswith("https://"):
parsed = urlparse(uri)
Expand Down
28 changes: 28 additions & 0 deletions tests/test_paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,34 @@ def test_relative_path(self) -> None:
assert result.scheme == "file"
assert result.path == "./bundles/my-bundle"

def test_windows_drive_letter_path(self) -> None:
"""Parses Windows drive-letter paths as file URIs."""
result = parse_uri("C:/Users/test/bundle")
assert result.scheme == "file"
assert result.path == "C:/Users/test/bundle"
assert result.is_file

def test_windows_drive_letter_backslash_path(self) -> None:
"""Parses Windows backslash drive-letter paths as file URIs."""
result = parse_uri(r"C:\Users\test\bundle")
assert result.scheme == "file"
assert result.path == r"C:\Users\test\bundle"
assert result.is_file

def test_windows_unc_path(self) -> None:
"""Parses Windows UNC paths as file URIs."""
result = parse_uri(r"\\server\share\bundle")
assert result.scheme == "file"
assert result.path == r"\\server\share\bundle"
assert result.is_file

def test_windows_file_uri_with_drive_letter(self) -> None:
"""Parses file:// URIs containing a drive letter."""
result = parse_uri("file://C:/Users/test/bundle")
assert result.scheme == "file"
assert result.path == "C:/Users/test/bundle"
assert result.is_file


class TestNormalizePath:
"""Tests for normalize_path function."""
Expand Down