strings are hard
Ted Unangst tedu@tedunangst.com
Sun, 30 Jul 2023 21:31:53 -0400
1 files changed,
4 insertions(+),
5 deletions(-)
jump to
M
honk.go
→
honk.go
@@ -145,15 +145,14 @@ return strings.Contains(noise, ">@"+nick) || strings.Contains(noise, "@<span>"+nick)
} func OntIsPresent(ont, noise string) bool { - ont = strings.ToLower(ont[1:] + "<") + ont = strings.ToLower(ont[1:]) idx := strings.IndexByte(noise, '#') for idx >= 0 { if strings.HasPrefix(noise[idx:], "#<span>") { - idx += 5 - } else { - idx += 1 + idx += 6 } - if idx + len(ont) + 1 > len(noise) { + idx += 1 + if idx + len(ont) >= len(noise) { return false } test := noise[idx:idx+len(ont)]