From 63901d43ce1642d35dfb21e5b66a06c2024f74cc Mon Sep 17 00:00:00 2001 From: thePR0M3TH3AN <53631862+PR0M3TH3AN@users.noreply.github.com> Date: Wed, 2 Jul 2025 20:39:08 -0400 Subject: [PATCH] update --- src/index.html | 55 ++++++++++++++++++++++++++++++-------------------- 1 file changed, 33 insertions(+), 22 deletions(-) diff --git a/src/index.html b/src/index.html index f66551f..bf9e406 100644 --- a/src/index.html +++ b/src/index.html @@ -32,7 +32,7 @@

Nostr Event Explorer

-

Enter a relay URL and an event ID (hex, note1..., or nevent1...). If an nevent is provided with relays, those will be used; otherwise, the specified relay will be used.

+

Enter a relay URL (optional if using nevent with relays) and an event ID (hex, note1..., or nevent1...).

0 ? dec.data.relays : [relay]; + if (dec.data.relays && dec.data.relays.length > 0) { + relaysToUse = dec.data.relays; + } else { + if (!relay) { + showError("Please provide a relay URL"); + return; + } + relaysToUse = [relay]; + } } else { showError("Invalid nevent"); return; @@ -88,36 +96,39 @@ showError("Invalid nevent"); return; } - } else if (eventIdInputClean.startsWith("note1")) { - try { - const dec = nip19.decode(eventIdInputClean); - if (dec.type === "note") { - eventId = dec.data; - relaysToUse = [relay]; - } else { + } else { + if (!relay) { + showError("Please provide a relay URL"); + return; + } + if (eventIdInputClean.startsWith("note1")) { + try { + const dec = nip19.decode(eventIdInputClean); + if (dec.type === "note") { + eventId = dec.data; + } else { + showError("Invalid note bech32"); + return; + } + } catch { showError("Invalid note bech32"); return; } - } catch { - showError("Invalid note bech32"); - return; + } else { + if (!/^[0-9a-f]{64}$/.test(eventIdInputClean)) { + showError("Invalid event ID: must be 64 hex characters"); + return; + } + eventId = eventIdInputClean; } - } else { - if (!/^[0-9a-f]{64}$/.test(eventIdInputClean)) { - showError("Invalid event ID: must be 64 hex characters"); - return; - } - eventId = eventIdInputClean; relaysToUse = [relay]; } - // Check if relaysToUse are valid if (relaysToUse.some(r => !r.startsWith("wss://"))) { showError("Invalid relay URL: must start with wss://"); return; } - // Fetch the event resultDiv.innerHTML = "

Loading...

"; try { const pool = new SimplePool(); @@ -126,7 +137,7 @@ const timer = setTimeout(() => { sub.unsub(); - pool.close(); + pool.close(relaysToUse); showError("Timeout: event not found"); }, TIMEOUT_MS); @@ -134,7 +145,7 @@ clearTimeout(timer); event = ev; sub.unsub(); - pool.close(); + pool.close(relaysToUse); displayEvent(event); });