From 22d448fa5f9e28cbdc1ee7b669e7198d06e1be1d Mon Sep 17 00:00:00 2001 From: Ted Unangst Date: Sun, 30 Jul 2023 21:31:53 -0400 Subject: [PATCH] strings are hard --- honk.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/honk.go b/honk.go index daf6526..8a9b86f 100644 --- a/honk.go +++ b/honk.go @@ -145,15 +145,14 @@ func (mention *Mention) IsPresent(noise string) bool { } 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:], "#") { - 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)]