fix .metadata.Website without a leading "https://"

This commit is contained in:
fiatjaf
2023-10-07 08:15:52 -03:00
parent b6a95e46db
commit f169c01e67
3 changed files with 9 additions and 1 deletions

View File

@@ -82,6 +82,7 @@ func main() {
"escapeString": html.EscapeString,
"sanitizeXSS": sanitizeXSS,
"trimProtocol": trimProtocol,
"normalizeWebsiteURL": normalizeWebsiteURL,
}
tmpl = template.Must(

View File

@@ -78,7 +78,7 @@
</header>
<div class="field separator long"></div>
<div class="field">
<a href="{{.metadata.Website | escapeString}}"
<a href="{{.metadata.Website | normalizeWebsiteURL | escapeString}}"
>{{.metadata.Website | escapeString}}</a
>
</div>

View File

@@ -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")