a few more serverURL conversions
Ted Unangst tedu@tedunangst.com
Mon, 19 Feb 2024 03:41:14 -0500
M
avatar.go
→
avatar.go
@@ -108,7 +108,7 @@ func avatarURL(user *WhatAbout) string {
if ava := user.Options.Avatar; ava != "" { return ava } - return fmt.Sprintf("https://%s/a?a=%s", serverName, url.QueryEscape(user.URL)) + return serverURL("/a?a=%s", url.QueryEscape(user.URL)) } func showflag(writer http.ResponseWriter, req *http.Request) {@@ -176,7 +176,7 @@ h.Noise = re_flags.ReplaceAllStringFunc(h.Noise, func(m string) string {
count++ var e Emu e.Name = fmt.Sprintf(":flag%d:", count) - e.ID = fmt.Sprintf("https://%s/flag/%s", serverName, m[5:]) + e.ID = serverURL("/flag/%s", m[5:]) emus = append(emus, e) return e.Name })@@ -186,7 +186,7 @@
func renderflags(h *Honk) { h.Noise = re_flags.ReplaceAllStringFunc(h.Noise, func(m string) string { code := m[5:] - src := fmt.Sprintf("https://%s/flag/%s", serverName, code) + src := serverURL("/flag/%s", code) return fmt.Sprintf(`<img class="emu" title="%s" src="%s">`, "flag", src) }) }
M
fun.go
→
fun.go
@@ -227,7 +227,7 @@ if d != nil {
zap[d.XID] = true base := "" if absolute { - base = "https://" + serverName + base = serverURL("") } return string(templates.Sprintf(`<img alt="%s" title="%s" src="%s/d/%s">`, alt, alt, base, d.XID)) }@@ -438,7 +438,7 @@ _, err := os.Stat(dataDir + "/emus/" + fname + ext)
if err != nil { continue } - url := fmt.Sprintf("https://%s/emu/%s%s", serverName, fname, ext) + url := serverURL("/emu/%s%s", fname, ext) if develMode { url = fmt.Sprintf("/emu/%s%s", fname, ext) }@@ -486,7 +486,7 @@ n, _ := fd.Read(peek[:])
ct := http.DetectContentType(peek[:n]) fd.Close() - url := fmt.Sprintf("https://%s/meme/%s", serverName, name) + url := serverURL("/meme/%s", name) fileid, err := savefile(name, name, url, ct, false, nil) if err != nil { elog.Printf("error saving meme: %s", err)@@ -608,8 +608,8 @@ return fmt.Sprintf(fill, html.EscapeString(where), html.EscapeString(who))
} func ontoreplacer(h string) string { - return fmt.Sprintf(`<a class="mention hashtag" href="https://%s/o/%s">%s</a>`, serverName, - strings.ToLower(h[1:]), h) + return fmt.Sprintf(`<a class="mention hashtag" href="%s">%s</a>`, + serverURL("/o/%s", strings.ToLower(h[1:])), h) } var re_unurl = regexp.MustCompile("https://([^/]+).*/([^/]+)")