From 7088986f21960c2c2f1e22ca741b75f3bfb3f5bd Mon Sep 17 00:00:00 2001 From: fiatjaf Date: Tue, 3 Oct 2023 15:33:35 -0300 Subject: [PATCH] strip querystring from relays. --- nostr.go | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/nostr.go b/nostr.go index 5350eca..bbc1d5d 100644 --- a/nostr.go +++ b/nostr.go @@ -5,7 +5,7 @@ import ( "encoding/json" "fmt" "math/rand" - "strings" + "net/url" "time" "github.com/nbd-wtf/go-nostr" @@ -169,17 +169,9 @@ func getEvent(ctx context.Context, code string) (*nostr.Event, []string, error) }() for ie := range pool.SubManyEoseNonUnique(ctx, relays, nostr.Filters{filter}) { - s := strings.TrimSuffix( - strings.TrimPrefix( - strings.TrimPrefix( - nostr.NormalizeURL(ie.Relay.URL), - "wss://", - ), - "ws://", - ), - "/", - ) - successRelays = append(successRelays, s) + if pu, err := url.Parse(ie.Relay.URL); err == nil { + successRelays = append(successRelays, pu.Host+pu.RawPath) + } result = ie.Event countdown = min(countdown, 1) }