Skip to content

Commit

Permalink
feat: expand tilde to home directory
Browse files Browse the repository at this point in the history
  • Loading branch information
bschoenmaeckers committed Sep 13, 2024
1 parent 544f389 commit ca0860c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ name = "netrc"
path = "src/lib.rs"

[dependencies]
shellexpand = { version = "3.1.0", features = ["base-0", "tilde", "path"], default-features = false }
thiserror = "1.0.56"

[workspace]
Expand Down
4 changes: 3 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ impl Netrc {
/// Look up the `NETRC` environment variable if it is defined else use the .netrc (or _netrc
/// file on windows) in the user's home directory.
pub fn get_file() -> Option<PathBuf> {
let env_var = std::env::var("NETRC").map(PathBuf::from);
let env_var = std::env::var("NETRC")
.map(PathBuf::from)
.map(|f| shellexpand::path::tilde(&f).into_owned());

#[cfg(windows)]
let default = std::env::var("USERPROFILE")
Expand Down

0 comments on commit ca0860c

Please sign in to comment.