From 1abb8e3f36ef2c21b7e1b3db0fbe771a7b13e5e7 Mon Sep 17 00:00:00 2001 From: Awiteb Date: Tue, 27 May 2025 10:48:33 +0000 Subject: [PATCH] feat: Events and naddrs can starts with `nostr:` Suggested-by: DanConwayDev Fixes: note1jwgfl095vuhduepxxpwhdqme0dnlhawzvcal0xnl0e6d82wx5jys5z92hj Signed-off-by: Awiteb --- src/cli/commands/reply.rs | 9 +++++---- src/cli/parsers.rs | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/cli/commands/reply.rs b/src/cli/commands/reply.rs index adee903..177ccbd 100644 --- a/src/cli/commands/reply.rs +++ b/src/cli/commands/reply.rs @@ -65,12 +65,13 @@ impl FromStr for NostrEvent { type Err = String; fn from_str(s: &str) -> Result { - if s.trim().starts_with("nevent1") { - let event = nip19::Nip19Event::from_bech32(s).map_err(|e| e.to_string())?; + let str_event = s.trim().trim_start_matches("nostr:"); + if str_event.starts_with("nevent1") { + let event = nip19::Nip19Event::from_bech32(str_event).map_err(|e| e.to_string())?; Ok(Self::new(event.event_id, event.relays)) - } else if s.trim().starts_with("note1") { + } else if str_event.starts_with("note1") { Ok(Self::new( - EventId::from_bech32(s).map_err(|e| e.to_string())?, + EventId::from_bech32(str_event).map_err(|e| e.to_string())?, Vec::new(), )) } else { diff --git a/src/cli/parsers.rs b/src/cli/parsers.rs index 92279ab..1db4f6f 100644 --- a/src/cli/parsers.rs +++ b/src/cli/parsers.rs @@ -83,7 +83,7 @@ pub fn parse_nostr_address_file(file_path: &Path) -> N34Result Result { - let repo = repo.trim(); + let repo = repo.trim().trim_start_matches("nostr:"); if repo.contains("/") { let (nip5, repo_id) = repo.split_once("/").expect("There is a `/`");