just be explicit about match checking

This commit is contained in:
Ted Unangst 2023-02-03 22:48:19 -05:00
parent 91db81b44d
commit 50524cade2
1 changed files with 2 additions and 3 deletions

5
fun.go
View File

@ -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]
}