From e9f9687db1329a5d645885160f419d979e911d73 Mon Sep 17 00:00:00 2001 From: Cyborus Date: Sun, 1 Sep 2024 11:52:51 -0400 Subject: fix: don't accept cannot-be-a-base urls in parsing --- src/repo.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/repo.rs b/src/repo.rs index e8f12d3..c8aa924 100644 --- a/src/repo.rs +++ b/src/repo.rs @@ -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()) }); -- cgit v1.2.3