adjust nip05 so it supports naked domains.

This commit is contained in:
fiatjaf 2023-02-05 16:21:40 -03:00
parent a16e2a28d5
commit e407725a43
No known key found for this signature in database
GPG Key ID: BAD43C4BE5C1A3A1

View File

@ -19,12 +19,23 @@ type WellKnownResponse struct {
func QueryIdentifier(fullname string) string {
spl := strings.Split(fullname, "@")
if len(spl) != 2 {
var name, domain string
switch len(spl) {
case 1:
name = "_"
domain = spl[0]
case 2:
name = spl[0]
domain = spl[1]
default:
return ""
}
if strings.Index(domain, ".") == -1 {
return ""
}
name := spl[0]
domain := spl[1]
res, err := http.Get(fmt.Sprintf("https://%s/.well-known/nostr.json?name=%s", domain, name))
if err != nil {
return ""