mirror of
https://github.com/nbd-wtf/go-nostr.git
synced 2025-12-05 18:32:35 +01:00
adjust nip05 so it supports naked domains.
This commit is contained in:
@@ -19,12 +19,23 @@ type WellKnownResponse struct {
|
|||||||
|
|
||||||
func QueryIdentifier(fullname string) string {
|
func QueryIdentifier(fullname string) string {
|
||||||
spl := strings.Split(fullname, "@")
|
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 ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
name := spl[0]
|
|
||||||
domain := spl[1]
|
|
||||||
res, err := http.Get(fmt.Sprintf("https://%s/.well-known/nostr.json?name=%s", domain, name))
|
res, err := http.Get(fmt.Sprintf("https://%s/.well-known/nostr.json?name=%s", domain, name))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ""
|
return ""
|
||||||
|
|||||||
Reference in New Issue
Block a user