strings are hard

This commit is contained in:
Ted Unangst 2023-07-30 21:31:53 -04:00
parent 8387dd4400
commit 22d448fa5f
1 changed files with 4 additions and 5 deletions

View File

@ -145,15 +145,14 @@ func (mention *Mention) IsPresent(noise string) bool {
} }
func OntIsPresent(ont, noise string) bool { func OntIsPresent(ont, noise string) bool {
ont = strings.ToLower(ont[1:] + "<") ont = strings.ToLower(ont[1:])
idx := strings.IndexByte(noise, '#') idx := strings.IndexByte(noise, '#')
for idx >= 0 { for idx >= 0 {
if strings.HasPrefix(noise[idx:], "#<span>") { if strings.HasPrefix(noise[idx:], "#<span>") {
idx += 5 idx += 6
} else {
idx += 1
} }
if idx + len(ont) + 1 > len(noise) { idx += 1
if idx + len(ont) >= len(noise) {
return false return false
} }
test := noise[idx:idx+len(ont)] test := noise[idx:idx+len(ont)]