Skip to content

Commit

Permalink
brain: fix panic on @ at end of message
Browse files Browse the repository at this point in the history
  • Loading branch information
zephyrtronium committed Aug 31, 2024
1 parent 7852ec4 commit ed98169
Showing 2 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions brain/words.go
Original file line number Diff line number Diff line change
@@ -33,6 +33,9 @@ func Tokens(dst []string, msg string) []string {
// write for a case that will be uncommon.
// In terms of control flow, we can fall through to the next case,
// after we skip past the @ itself.
if l == len(msg) {
break
}
l++
fallthrough
case unicode.Is(ln, c):
5 changes: 5 additions & 0 deletions brain/words_test.go
Original file line number Diff line number Diff line change
@@ -53,6 +53,11 @@ func TestWords(t *testing.T) {
msg: "@bocchi ryo",
want: s("@bocchi ", "ryo "),
},
{
name: "at-end",
msg: "bocchi@",
want: s("bocchi", "@ "),
},
}
for _, c := range cases {
t.Run(c.name, func(t *testing.T) {

0 comments on commit ed98169

Please sign in to comment.