mirror of
https://github.com/nbd-wtf/go-nostr.git
synced 2025-07-16 14:32:20 +02:00
validate and normalize relay urls received from kind 3 and 10002.
This commit is contained in:
@ -56,6 +56,11 @@ func ParseRelaysFromKind10002(evt *nostr.Event) []Relay {
|
||||
result := make([]Relay, 0, len(evt.Tags))
|
||||
for _, tag := range evt.Tags {
|
||||
if u := tag.Value(); u != "" && tag[0] == "r" {
|
||||
if !nostr.IsValidRelayURL(u) {
|
||||
continue
|
||||
}
|
||||
u := nostr.NormalizeURL(u)
|
||||
|
||||
relay := Relay{
|
||||
URL: u,
|
||||
}
|
||||
@ -88,6 +93,11 @@ func ParseRelaysFromKind3(evt *nostr.Event) []Relay {
|
||||
results := make([]Relay, len(items))
|
||||
i := 0
|
||||
for u, item := range items {
|
||||
if !nostr.IsValidRelayURL(u) {
|
||||
continue
|
||||
}
|
||||
u := nostr.NormalizeURL(u)
|
||||
|
||||
relay := Relay{
|
||||
URL: u,
|
||||
}
|
||||
|
Reference in New Issue
Block a user