From 543a16f6f467a45319120850b244f57708e8f537 Mon Sep 17 00:00:00 2001 From: Ted Unangst Date: Thu, 10 Oct 2019 18:51:09 -0400 Subject: [PATCH] allow renames at end of noise --- fun.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/fun.go b/fun.go index 37e5a9b..3383c44 100644 --- a/fun.go +++ b/fun.go @@ -326,14 +326,13 @@ func memetize(honk *Honk) { honk.Noise = re_memes.ReplaceAllStringFunc(honk.Noise, repl) } -var re_quickmention = regexp.MustCompile("(^| )@[[:alnum:]]+ ") +var re_quickmention = regexp.MustCompile("(^| )@[[:alnum:]]+( |$)") func quickrename(s string, userid int64) string { nonstop := true for nonstop { nonstop = false s = re_quickmention.ReplaceAllStringFunc(s, func(m string) string { - log.Printf("m: %s", m) prefix := "" if m[0] == ' ' { prefix = " " @@ -341,7 +340,9 @@ func quickrename(s string, userid int64) string { } prefix += "@" m = m[1:] - m = m[:len(m)-1] + if m[len(m)-1] == ' ' { + m = m[:len(m)-1] + } row := stmtOneHonker.QueryRow(m, userid) var xid string