diff options
author | Jesse Luehrs <doy@tozt.net> | 2020-05-03 04:07:03 -0400 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2020-05-03 04:09:34 -0400 |
commit | dbdd8a78951f8a44630abcceb7b13d0d823ee074 (patch) | |
tree | 64c69f16279876c71ba22a55ef6dd255289aaaef /src/dirs.rs | |
parent | 6ebf7d55e4c553870306a70092cfb677c17429b9 (diff) | |
download | rbw-dbdd8a78951f8a44630abcceb7b13d0d823ee074.tar.gz rbw-dbdd8a78951f8a44630abcceb7b13d0d823ee074.zip |
allow storing password databases from different servers
this should allow easy switching of servers by just `rbw config set
base_url`
Diffstat (limited to 'src/dirs.rs')
-rw-r--r-- | src/dirs.rs | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/dirs.rs b/src/dirs.rs index 5dd2c35..53a433e 100644 --- a/src/dirs.rs +++ b/src/dirs.rs @@ -17,8 +17,13 @@ pub fn config_file() -> std::path::PathBuf { config_dir().join("config.json") } -pub fn db_file(email: &str) -> std::path::PathBuf { - cache_dir().join(format!("{}.json", email)) +const INVALID_PATH: &percent_encoding::AsciiSet = + &percent_encoding::CONTROLS.add(b'/').add(b'%').add(b':'); +pub fn db_file(server: &str, email: &str) -> std::path::PathBuf { + let server = + percent_encoding::percent_encode(server.as_bytes(), INVALID_PATH) + .to_string(); + cache_dir().join(format!("{}:{}.json", server, email)) } pub fn pid_file() -> std::path::PathBuf { |