Skip to content

Commit

Permalink
Merge #347: Remove trailing slash from relay in NWC uri
Browse files Browse the repository at this point in the history
  • Loading branch information
yukibtc committed Mar 11, 2024
2 parents ac40341 + 25b271d commit 8399ec6
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions crates/nostr/src/nips/nip47.rs
Original file line number Diff line number Diff line change
Expand Up @@ -940,11 +940,14 @@ impl FromStr for NostrWalletConnectURI {

impl fmt::Display for NostrWalletConnectURI {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
// trailing slash is removed, this breaks some clients
let relay_url = self.relay_url.to_string();
let relay_url = relay_url.strip_suffix('/').unwrap_or(&relay_url);
write!(
f,
"{NOSTR_WALLET_CONNECT_URI_SCHEME}://{}?relay={}&secret={}",
self.public_key,
url_encode(self.relay_url.to_string()),
url_encode(relay_url),
url_encode(self.secret.to_secret_hex())
)?;
if let Some(lud16) = &self.lud16 {
Expand Down Expand Up @@ -996,7 +999,7 @@ mod test {
);
assert_eq!(
uri.to_string(),
"nostr+walletconnect://b889ff5b1513b641e2a139f661a661364979c5beee91842f8f0ef42ab558e9d4?relay=wss%3A%2F%2Frelay.damus.io%2F&secret=71a8c14c1407c113601079c4302dab36460f0ccd0ad506f1f2dc73b5100e4f3c&lud16=nostr%40nostr.com".to_string()
"nostr+walletconnect://b889ff5b1513b641e2a139f661a661364979c5beee91842f8f0ef42ab558e9d4?relay=wss%3A%2F%2Frelay.damus.io&secret=71a8c14c1407c113601079c4302dab36460f0ccd0ad506f1f2dc73b5100e4f3c&lud16=nostr%40nostr.com".to_string()
);
}

Expand Down

0 comments on commit 8399ec6

Please sign in to comment.