Skip to content

Commit

Permalink
Fix ssh url -> local directory mapping (#22)
Browse files Browse the repository at this point in the history
This is the fix for
EmbarkStudios/cargo-deny#548 as the hash was
correct since it takes the entirety of the user provided url into
account, but it wasn't stripping off the user portion of the url causing
it to look at the wrong local directory.
  • Loading branch information
Jake-Shadle authored Aug 23, 2023
1 parent 5b16ea5 commit 295b98c
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ pub fn url_to_local_dir(url: &str) -> Result<UrlDir, Error> {

// 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())
};
Expand Down Expand Up @@ -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]
Expand Down

0 comments on commit 295b98c

Please sign in to comment.