From 8bb2593143d064a03587f462199926b51e97deee Mon Sep 17 00:00:00 2001 From: Edvin Ã…kerfeldt Date: Thu, 14 Dec 2023 09:21:57 +0100 Subject: Fix bitwarden.eu URLs Bitwarden have introduced an eu instance of their service. This needs to be reflected in the code by excluding the eu addresses from URL formatting. --- src/config.rs | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/src/config.rs b/src/config.rs index 03a9641..557bfc0 100644 --- a/src/config.rs +++ b/src/config.rs @@ -146,7 +146,14 @@ 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.trim_end_matches('/')), + |url| { + let clean_url = format!("{}", url.trim_end_matches('/')); + if clean_url == "https://api.bitwarden.eu" { + clean_url + } else { + format!("{}/api", clean_url) + } + }, ) } @@ -155,7 +162,14 @@ 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.trim_end_matches('/')), + |url| { + let clean_url = format!("{}", url.trim_end_matches('/')); + if clean_url == "https://identity.bitwarden.eu" { + clean_url + } else { + format!("{}/identity", clean_url) + } + } ) }) } @@ -165,7 +179,14 @@ impl Config { self.notifications_url.clone().unwrap_or_else(|| { self.base_url.clone().map_or_else( || "https://notifications.bitwarden.com".to_string(), - |url| format!("{}/notifications", url.trim_end_matches('/')), + |url| { + let clean_url = format!("{}", url.trim_end_matches('/')); + if clean_url == "https://notifications.bitwarden.eu" { + clean_url + } else { + format!("{}/notifications", clean_url) + } + } ) }) } -- cgit v1.2.3-54-g00ecf