fix: don't accept cannot-be-a-base urls in parsing

This commit is contained in:
Cyborus 2024-09-01 11:52:51 -04:00
parent e8e6d47743
commit e9f9687db1
No known key found for this signature in database

View file

@ -49,11 +49,10 @@ impl RepoInfo {
if let Some(repo) = repo {
if let Some(host) = &repo.host {
if let Ok(url) = Url::parse(host) {
repo_url = Some(url);
} else if let Ok(url) = Url::parse(&format!("https://{host}/")) {
repo_url = Some(url);
}
repo_url = Url::parse(host)
.ok()
.filter(|x| !x.cannot_be_a_base())
.or_else(|| Url::parse(&format!("https://{host}/")).ok())
}
repo_name = Some(RepoName {
owner: repo.owner.clone(),
@ -67,6 +66,7 @@ impl RepoInfo {
let host_url = host.and_then(|host| {
Url::parse(host)
.ok()
.filter(|x| !x.cannot_be_a_base())
.or_else(|| Url::parse(&format!("https://{host}/")).ok())
});