summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/main.rs12
-rw-r--r--src/repo.rs6
2 files changed, 15 insertions, 3 deletions
diff --git a/src/main.rs b/src/main.rs
index 8e7ff0e..f224abd 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -211,6 +211,18 @@ async fn tempfile(ext: Option<&str>) -> tokio::io::Result<(tokio::fs::File, std:
Ok((file, path))
}
+fn ssh_url_parse(s: &str) -> Result<url::Url, url::ParseError> {
+ url::Url::parse(s).or_else(|_| {
+ let mut new_s = String::new();
+ new_s.push_str("ssh://");
+
+ let auth_end = s.find("@").unwrap_or(0);
+ new_s.push_str(&s[..auth_end]);
+ new_s.push_str(&s[..auth_end].replacen(":", "/", 1));
+ url::Url::parse(&new_s)
+ })
+}
+
use std::sync::OnceLock;
static SPECIAL_RENDER: OnceLock<SpecialRender> = OnceLock::new();
diff --git a/src/repo.rs b/src/repo.rs
index 07370d3..e8f12d3 100644
--- a/src/repo.rs
+++ b/src/repo.rs
@@ -97,7 +97,7 @@ impl RepoInfo {
if let Some(host_url) = &host_url {
let remote = local_repo.find_remote(remote_name_s)?;
let url_s = std::str::from_utf8(remote.url_bytes())?;
- let url = Url::parse(url_s)?;
+ let url = crate::ssh_url_parse(url_s)?;
if url.host_str() == host_url.host_str() {
name = Some(remote_name_s.to_owned());
@@ -123,7 +123,7 @@ impl RepoInfo {
let remote = local_repo.find_remote(remote_name)?;
if let Some(url) = remote.url() {
- let (url, _) = url_strip_repo_name(Url::parse(url)?)?;
+ let (url, _) = url_strip_repo_name(crate::ssh_url_parse(url)?)?;
if url.host_str() == host_url.host_str()
&& url.path() == host_url.path()
{
@@ -138,7 +138,7 @@ impl RepoInfo {
if let Some(name) = name {
if let Ok(remote) = local_repo.find_remote(&name) {
let url_s = std::str::from_utf8(remote.url_bytes())?;
- let url = Url::parse(url_s)?;
+ let url = crate::ssh_url_parse(url_s)?;
let (url, name) = url_strip_repo_name(url)?;
out = (Some(url), Some(name))