fix titlecasing of roles in calendar event template.

This commit is contained in:
fiatjaf
2024-09-19 21:04:14 -03:00
parent 928a55238d
commit 5914e2a076

View File

@@ -3,7 +3,6 @@ package main
import ( import (
_ "embed" _ "embed"
"strings" "strings"
"unicode"
"html/template" "html/template"
"github.com/nbd-wtf/go-nostr/nip19" "github.com/nbd-wtf/go-nostr/nip19"
"github.com/nbd-wtf/go-nostr/nip52" "github.com/nbd-wtf/go-nostr/nip52"
@@ -28,12 +27,9 @@ func formatParticipants(participants []nip52.Participant) string {
var list = make([]string, 0) var list = make([]string, 0)
for _, p := range participants { for _, p := range participants {
nreplace, _ := nip19.EncodePublicKey(p.PubKey) nreplace, _ := nip19.EncodePublicKey(p.PubKey)
bytes := []byte(p.Role)
bytes[0] = byte(unicode.ToUpper(rune(bytes[0])))
role := string(bytes)
nreplace = replaceNostrURLsWithHTMLTags(nostrNpubNprofileMatcher, "nostr:"+nreplace) nreplace = replaceNostrURLsWithHTMLTags(nostrNpubNprofileMatcher, "nostr:"+nreplace)
if p.Role != "" { if p.Role != "" {
nreplace = nreplace + " as " + role nreplace = nreplace + " as " + strings.ToTitle(p.Role)
} }
list = append(list, nreplace) list = append(list, nreplace)
} }