From 50524cade2d1236e4be684993f0bfd470b240452 Mon Sep 17 00:00:00 2001 From: Ted Unangst Date: Fri, 3 Feb 2023 22:48:19 -0500 Subject: [PATCH] just be explicit about match checking --- fun.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/fun.go b/fun.go index c8afcfa..8226cd0 100644 --- a/fun.go +++ b/fun.go @@ -27,7 +27,6 @@ import ( "regexp" "strings" "time" - "unicode" "golang.org/x/net/html" "humungus.tedunangst.com/r/webs/cache" @@ -458,7 +457,6 @@ func memetize(honk *Honk) { honk.Noise = re_memes.ReplaceAllStringFunc(honk.Noise, repl) } -// be mindful not to match trailing @ var re_quickmention = regexp.MustCompile("(^|[ \n])@[[:alnum:]]+([ \n.,']|$)") func quickrename(s string, userid int64) string { @@ -474,7 +472,8 @@ func quickrename(s string, userid int64) string { prefix += "@" m = m[1:] tail := "" - if last := m[len(m)-1]; last == ' ' || last == '\n' || unicode.IsPunct(rune(last)) { + if last := m[len(m)-1]; last == ' ' || last == '\n' || + last == '.' || last == ',' || last == '\'' { tail = m[len(m)-1:] m = m[:len(m)-1] }