don't link missing mentions
Ted Unangst tedu@tedunangst.com
Mon, 15 Apr 2019 23:48:01 -0400
1 files changed,
5 insertions(+),
1 deletions(-)
jump to
M
fun.go
→
fun.go
@@ -181,7 +181,11 @@ s = re_link.ReplaceAllStringFunc(s, linkfn)
s = strings.Replace(s, "\n", "<br>", -1) s = re_mentions.ReplaceAllStringFunc(s, func(m string) string { - return fmt.Sprintf(`<a href="%s">%s</a>`, html.EscapeString(gofish(m)), + where := gofish(m) + if where == "" { + return m + } + return fmt.Sprintf(`<a href="%s">%s</a>`, html.EscapeString(where), html.EscapeString(m)) }) return s