Skip to content
This repository was archived by the owner on Jan 21, 2026. It is now read-only.

Commit b374316

Browse files
committed
treat URL as direct link if only it has scheme and host
1 parent 39bcb4e commit b374316

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

src/error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ impl Display for PlatformError {
7878
PlatformError::ApiError { status } => write!(f, "API error [{}]", status),
7979
PlatformError::DownloadError(err) => write!(f, "Download error: {}", err),
8080
PlatformError::InvalidInput(msg) => {
81-
write!(f, "{} is invalid. Should be in format (owner/repo)", msg)
81+
write!(f, "{} is invalid", msg)
8282
}
8383
PlatformError::InvalidResponse => write!(f, "Failed to parse response"),
8484
PlatformError::NoRelease { tag } => write!(

src/platform.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ impl PlatformUrl {
5959
return Ok(PlatformUrl::Github(project.to_string()));
6060
}
6161
}
62+
6263
return Err(PlatformError::InvalidInput(url));
6364
}
6465
if GITLAB_RELEASE_RE.is_match(&url) {
@@ -81,8 +82,13 @@ impl PlatformUrl {
8182
}
8283
return Err(PlatformError::InvalidInput(url));
8384
}
84-
let url = Url::parse(&url).map_err(|_| PlatformError::InvalidInput(url))?;
85-
Ok(PlatformUrl::DirectUrl(url.to_string()))
85+
86+
match Url::parse(&url) {
87+
Ok(parsed) if !parsed.scheme().is_empty() && parsed.host().is_some() => {
88+
Ok(PlatformUrl::DirectUrl(parsed.to_string()))
89+
}
90+
_ => Err(PlatformError::InvalidInput(url)),
91+
}
8692
}
8793
}
8894

0 commit comments

Comments
 (0)