From 892065339daafeca26f41aa478fef8d8e6765cfc Mon Sep 17 00:00:00 2001 From: fiatjaf Date: Sun, 24 Sep 2023 13:58:03 -0300 Subject: [PATCH] fix grabData() bug with npub codes being trimmed. --- render.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/render.go b/render.go index c709423..45ea236 100644 --- a/render.go +++ b/render.go @@ -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 event, err := getEvent(ctx, code) if err != nil { + log.Warn().Err(err).Str("code", code).Msg("failed to fetch event for code") return nil, err } @@ -241,11 +242,9 @@ func render(w http.ResponseWriter, r *http.Request) { return } else if strings.HasPrefix(code, "nostr:") { 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] - if strings.HasSuffix(code, ".xml") { - isProfileSitemap = true - } } if strings.HasPrefix(code, "note1") {