Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

Commit

Permalink
clap-utils: Add explicit schemes for ask and file SignerSources
Browse files Browse the repository at this point in the history
  • Loading branch information
t-nelson committed Apr 16, 2021
1 parent a33be0b commit e2a9ef5
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions clap-utils/src/keypair.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ pub(crate) fn parse_signer_source<S: AsRef<str>>(source: S) -> SignerSource {
if let Some(scheme) = uri.scheme() {
let scheme = scheme.as_str().to_ascii_lowercase();
match scheme.as_str() {
"ask" => SignerSource::Ask,
"file" => SignerSource::Filepath(uri.path().to_string()),
"usb" => SignerSource::Usb(source.to_string()),
_ => SignerSource::Filepath(source.to_string()),
}
Expand Down Expand Up @@ -473,5 +475,11 @@ mod tests {
assert!(Pubkey::from_str(&junk).is_err());
assert!(matches!(parse_signer_source(&junk), SignerSource::Filepath(j) if j == junk));

let ask = "ask:".to_string();
assert!(matches!(parse_signer_source(&ask), SignerSource::Ask));
let path = "/absolute/path".to_string();
assert!(matches!(parse_signer_source(&format!("file:{}", path)), SignerSource::Filepath(p) if p == path));
let path = "relative/path".to_string();
assert!(matches!(parse_signer_source(&format!("file:{}", path)), SignerSource::Filepath(p) if p == path));
}
}

0 comments on commit e2a9ef5

Please sign in to comment.