From 2395afe7cf1615ccaa1918f18027b6aaec3924ad Mon Sep 17 00:00:00 2001 From: jake Date: Wed, 23 Aug 2023 14:29:20 +0200 Subject: [PATCH] Fix ssh url -> local directory mapping --- src/utils.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/utils.rs b/src/utils.rs index d853af1..b0fca2d 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -185,6 +185,7 @@ pub fn url_to_local_dir(url: &str) -> Result { // trim port let host = host.split(':').next().unwrap(); + let host = host.split_once('@').map_or(host, |(_user, host)| host); (format!("{host}-{ident}"), url.to_owned()) }; @@ -305,6 +306,17 @@ mod test { assert_eq!("https://gitlab.com/gilrs-project/gilrs", canonical); assert_eq!("gilrs-7804d1d6a17891c9", dir_name); + + let super::UrlDir { + dir_name, + canonical, + } = url_to_local_dir("ssh://git@github.com/rust-lang/crates.io-index.git").unwrap(); + + assert_eq!( + "ssh://git@github.com/rust-lang/crates.io-index.git", + canonical + ); + assert_eq!("github.com-01dba724c7458575", dir_name); } #[test]