Skip to content

Commit 1cf789a

Browse files
authored
Merge pull request #53 from fiatjaf/fix/nsite-host-normalize
Normalize host before resolving nsite so port and case do not break lookup
2 parents 712e199 + b46dd10 commit 1cf789a

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

nsite/helpers.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package nsite
22

33
import (
44
"fmt"
5+
"net"
56
"strings"
67

78
"fiatjaf.com/nostr"
@@ -10,6 +11,13 @@ import (
1011
)
1112

1213
func resolveSite(host string) (nostr.Event, error) {
14+
// normalize the incoming host the same way the caller does before MatchesHost
15+
host = strings.TrimSpace(host)
16+
if h, _, err := net.SplitHostPort(host); err == nil {
17+
host = h
18+
}
19+
host = strings.ToLower(host)
20+
1321
domain := strings.Trim(strings.ToLower(global.Settings.Nsite.Domain), ".")
1422
if host == domain {
1523
return nostr.Event{}, fmt.Errorf("domain mismatch")

0 commit comments

Comments
 (0)