Skip to content

Commit 0bcbabf

Browse files
committed
feat: shrink repeated patterns
1 parent 421e719 commit 0bcbabf

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

chat/init.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,16 @@ func AskCustom[T any](grp int64, f func(int, string) T) []T {
4949
func Sanitize(msg string) string {
5050
i := strings.LastIndex(msg, "】")
5151
if i > 0 {
52-
msg = msg[i:]
52+
if i+1 >= len(msg) {
53+
return ""
54+
}
55+
msg = msg[i+1:]
5356
} else {
5457
i = strings.LastIndex(msg, "]")
5558
if i > 0 {
59+
if i+1 >= len(msg) {
60+
return ""
61+
}
5662
msg = msg[i:]
5763
}
5864
}

0 commit comments

Comments
 (0)