From 5abfa90cafd51470e003402b9aa21ad94617f657 Mon Sep 17 00:00:00 2001 From: Cyborus Date: Thu, 5 Sep 2024 14:31:02 -0400 Subject: [PATCH] fix: make sure urls are http(s) and remove username --- src/repo.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 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 },