diff options
author | Cyborus <cyborus@cyborus.xyz> | 2024-08-30 18:13:31 +0200 |
---|---|---|
committer | Cyborus <cyborus@cyborus.xyz> | 2024-08-30 18:13:31 +0200 |
commit | 163e789ec223a4a2c7668520c27b065c0de58cda (patch) | |
tree | 8884990dcd8cf93af511af94e2de67aaffb28aec /src/main.rs | |
parent | Merge pull request 'Squish clippy and audit errors/warnings' (#120) from Pi-C... (diff) | |
download | forgejo-cli-163e789ec223a4a2c7668520c27b065c0de58cda.tar.xz forgejo-cli-163e789ec223a4a2c7668520c27b065c0de58cda.zip |
fix: correctly parse ssh urls from git remotes
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 12 |
1 files changed, 12 insertions, 0 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(); |