Merge pull request 'clean up urls better' (#126) from url-cleanup into main

Reviewed-on: https://codeberg.org/Cyborus/forgejo-cli/pulls/126
This commit is contained in:
Cyborus 2024-09-05 20:33:17 +00:00
commit b7aa1e95b6

View file

@ -166,7 +166,15 @@ impl RepoInfo {
(host_url, None) (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) { let info = match (url, name) {
(Some(url), name) => RepoInfo { url, name }, (Some(url), name) => RepoInfo { url, name },