summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCyborus <cyborus@cyborus.xyz>2024-09-01 17:52:51 +0200
committerCyborus <cyborus@cyborus.xyz>2024-09-01 17:52:51 +0200
commite9f9687db1329a5d645885160f419d979e911d73 (patch)
tree221dc68e1ea8e9ec4a372cd5c3cfd80786afffaa
parentMerge pull request 'correctly parse ssh urls from git remotes' (#121) from ss... (diff)
downloadforgejo-cli-e9f9687db1329a5d645885160f419d979e911d73.tar.xz
forgejo-cli-e9f9687db1329a5d645885160f419d979e911d73.zip
fix: don't accept cannot-be-a-base urls in parsing
-rw-r--r--src/repo.rs10
1 files 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())
});