Fix Windows marketplace local source parsing

This commit is contained in:
Joe Gershenson
2026-04-14 22:35:27 -07:00
parent 0bb438bca6
commit 6703333d2a

View File

@@ -130,6 +130,16 @@ fn looks_like_local_path(source: &str) -> bool {
|| source.starts_with("~/")
|| source == "."
|| source == ".."
|| {
#[cfg(windows)]
{
source.starts_with(".\\") || source.starts_with("..\\") || source.starts_with('\\')
}
#[cfg(not(windows))]
{
false
}
}
}
fn resolve_local_source_path(source: &str) -> Result<PathBuf, MarketplaceAddError> {
@@ -310,6 +320,14 @@ mod tests {
assert!(path.is_absolute());
}
#[cfg(windows)]
#[test]
fn windows_backslash_relative_path_looks_local() {
assert!(looks_like_local_path(r".\marketplace"));
assert!(looks_like_local_path(r"..\marketplace"));
assert!(looks_like_local_path(r"\marketplace"));
}
#[test]
fn local_file_source_is_rejected() {
let tempdir = TempDir::new().unwrap();