feat: Events and naddrs can starts with nostr:

Suggested-by: DanConwayDev <DanConwayDev@protonmail.com>
Fixes: note1jwgfl095vuhduepxxpwhdqme0dnlhawzvcal0xnl0e6d82wx5jys5z92hj
Signed-off-by: Awiteb <a@4rs.nl>
This commit is contained in:
Awiteb
2025-05-27 10:48:33 +00:00
parent 15d834dc0f
commit 1abb8e3f36
2 changed files with 6 additions and 5 deletions

View File

@@ -65,12 +65,13 @@ impl FromStr for NostrEvent {
type Err = String;
fn from_str(s: &str) -> Result<Self, Self::Err> {
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 {