diff options
author | Cyborus <cyborus@noreply.codeberg.org> | 2024-09-01 17:56:35 +0200 |
---|---|---|
committer | Cyborus <cyborus@noreply.codeberg.org> | 2024-09-01 17:56:35 +0200 |
commit | 23311d2807c8e8396042f17bb88680ab86a63352 (patch) | |
tree | 221dc68e1ea8e9ec4a372cd5c3cfd80786afffaa | |
parent | Merge pull request 'correctly parse ssh urls from git remotes' (#121) from ss... (diff) | |
parent | fix: don't accept cannot-be-a-base urls in parsing (diff) | |
download | forgejo-cli-23311d2807c8e8396042f17bb88680ab86a63352.tar.xz forgejo-cli-23311d2807c8e8396042f17bb88680ab86a63352.zip |
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
-rw-r--r-- | src/repo.rs | 10 |
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()) }); |