diff options
author | Cyborus <cyborus@noreply.codeberg.org> | 2024-09-05 22:33:17 +0200 |
---|---|---|
committer | Cyborus <cyborus@noreply.codeberg.org> | 2024-09-05 22:33:17 +0200 |
commit | b7aa1e95b6b697b122035a7134596762ade8422a (patch) | |
tree | 2c196ec850e42a17c1cca478bb958f0090fef300 | |
parent | Merge pull request 'host aliases' (#125) from alias-host into main (diff) | |
parent | fix: make sure urls are http(s) and remove username (diff) | |
download | forgejo-cli-b7aa1e95b6b697b122035a7134596762ade8422a.tar.xz forgejo-cli-b7aa1e95b6b697b122035a7134596762ade8422a.zip |
Merge pull request 'clean up urls better' (#126) from url-cleanup into main
Reviewed-on: https://codeberg.org/Cyborus/forgejo-cli/pulls/126
-rw-r--r-- | src/repo.rs | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/repo.rs b/src/repo.rs index c55c51b..7c76b61 100644 --- a/src/repo.rs +++ b/src/repo.rs @@ -166,7 +166,15 @@ impl RepoInfo { (host_url, None) }; - let url = url.or_else(fallback_host); + let url = url.or_else(fallback_host).map(|url| { + let mut url = match url.scheme() { + "http" | "https" => url, + _ => url::Url::parse(&format!("https{}", &url[url::Position::AfterScheme..])) + .expect("should always be valid"), + }; + url.set_username("").expect("shouldn't fail"); + url + }); let info = match (url, name) { (Some(url), name) => RepoInfo { url, name }, |