Merge pull request 'don't accept cannot-be-a-base urls in parsing' (#123) from not-base-fix into main

Reviewed-on: https://codeberg.org/Cyborus/forgejo-cli/pulls/123
This commit is contained in:
Cyborus 2024-09-01 15:56:35 +00:00
commit 23311d2807

View file

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