fix grabData() bug with npub codes being trimmed.

This commit is contained in:
fiatjaf
2023-09-24 13:58:03 -03:00
parent a082efc45d
commit 892065339d

View File

@@ -53,6 +53,7 @@ func grabData(ctx context.Context, code string, isProfileSitemap bool) (*Data, e
// code can be a nevent, nprofile, npub or nip05 identifier, in which case we try to fetch the associated event // code can be a nevent, nprofile, npub or nip05 identifier, in which case we try to fetch the associated event
event, err := getEvent(ctx, code) event, err := getEvent(ctx, code)
if err != nil { if err != nil {
log.Warn().Err(err).Str("code", code).Msg("failed to fetch event for code")
return nil, err return nil, err
} }
@@ -241,11 +242,9 @@ func render(w http.ResponseWriter, r *http.Request) {
return return
} else if strings.HasPrefix(code, "nostr:") { } else if strings.HasPrefix(code, "nostr:") {
http.Redirect(w, r, "/"+code[6:], http.StatusFound) http.Redirect(w, r, "/"+code[6:], http.StatusFound)
} else if strings.HasPrefix(code, "npub") { } else if strings.HasPrefix(code, "npub") && strings.HasSuffix(code, ".xml") {
isProfileSitemap = true
code = code[:len(code)-4] code = code[:len(code)-4]
if strings.HasSuffix(code, ".xml") {
isProfileSitemap = true
}
} }
if strings.HasPrefix(code, "note1") { if strings.HasPrefix(code, "note1") {