From f169c01e676836d4169f3da9c434841cf085108a Mon Sep 17 00:00:00 2001 From: fiatjaf Date: Sat, 7 Oct 2023 08:15:52 -0300 Subject: [PATCH] fix .metadata.Website without a leading "https://" --- main.go | 1 + templates/profile.html | 2 +- utils.go | 7 +++++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 3899b07..ef4be85 100644 --- a/main.go +++ b/main.go @@ -82,6 +82,7 @@ func main() { "escapeString": html.EscapeString, "sanitizeXSS": sanitizeXSS, "trimProtocol": trimProtocol, + "normalizeWebsiteURL": normalizeWebsiteURL, } tmpl = template.Must( diff --git a/templates/profile.html b/templates/profile.html index fd34d77..e1843a2 100644 --- a/templates/profile.html +++ b/templates/profile.html @@ -78,7 +78,7 @@
- {{.metadata.Website | escapeString}}
diff --git a/utils.go b/utils.go index 85d58a0..58d3bdf 100644 --- a/utils.go +++ b/utils.go @@ -435,6 +435,13 @@ func trimProtocol(relay string) string { return relay } +func normalizeWebsiteURL(u string) string { + if strings.HasPrefix(u, "http") { + return u + } + return "https://" + u +} + func loadNpubsArchive(ctx context.Context) { log.Debug().Msg("refreshing the npubs archive")