From a9aa71fa25fdc347e3a13dbaeea3cd3d3eb06b10 Mon Sep 17 00:00:00 2001 From: thesimplekid Date: Sun, 17 Sep 2023 20:44:30 +0100 Subject: [PATCH] strip trailing `/` from token min url --- crates/cashu-sdk/src/client/mod.rs | 5 ----- crates/cashu/src/url.rs | 2 +- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/crates/cashu-sdk/src/client/mod.rs b/crates/cashu-sdk/src/client/mod.rs index 56925c79..206a2440 100644 --- a/crates/cashu-sdk/src/client/mod.rs +++ b/crates/cashu-sdk/src/client/mod.rs @@ -122,11 +122,6 @@ pub struct Client { impl Client { pub fn new(mint_url: &str) -> Result { - // HACK - let mut mint_url = String::from(mint_url); - if !mint_url.ends_with('/') { - mint_url.push('/'); - } let mint_url = Url::parse(&mint_url)?; Ok(Self { mint_url }) } diff --git a/crates/cashu/src/url.rs b/crates/cashu/src/url.rs index 8158046f..72dcb434 100644 --- a/crates/cashu/src/url.rs +++ b/crates/cashu/src/url.rs @@ -85,7 +85,7 @@ impl TryFrom<&UncheckedUrl> for Url { impl fmt::Display for UncheckedUrl { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "{}", self.0) + write!(f, "{}", self.0.strip_suffix("/").unwrap_or(&self.0)) } }