From 95c29fd68cda5748d4e1cb3f02c5c7a0b202454b Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Sun, 18 Apr 2021 00:08:46 -0400 Subject: avoid generating urls with double slashes apparently the official bitwarden server doesn't like it --- CHANGELOG.md | 2 ++ src/config.rs | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a0510fd..43fbddd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,8 @@ * `rbw generate` can now choose the same character more than once (#54, rjc) * Improved handling of password history for entries with no password (#51/#53, simias) +* Fix configuring base_url with a trailing slash when using a self-hosted + version of the official bitwarden server (#49, phylor) ## [1.1.2] - 2021-03-06 diff --git a/src/config.rs b/src/config.rs index dbdf759..c6e0787 100644 --- a/src/config.rs +++ b/src/config.rs @@ -126,7 +126,7 @@ impl Config { pub fn base_url(&self) -> String { self.base_url.clone().map_or_else( || "https://api.bitwarden.com".to_string(), - |url| format!("{}/api", url), + |url| format!("{}/api", url.trim_end_matches('/')), ) } @@ -134,7 +134,7 @@ impl Config { self.identity_url.clone().unwrap_or_else(|| { self.base_url.clone().map_or_else( || "https://identity.bitwarden.com".to_string(), - |url| format!("{}/identity", url), + |url| format!("{}/identity", url.trim_end_matches('/')), ) }) } -- cgit v1.2.3