From 66e81e31e7f11e04fc3a0602452cb3052a3a4c57 Mon Sep 17 00:00:00 2001 From: Ben Boyter Date: Thu, 12 Mar 2020 08:41:56 +1100 Subject: [PATCH] Resolve final bug --- string/index.go | 2 +- string/index_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/string/index.go b/string/index.go index babab9e..720f3fa 100644 --- a/string/index.go +++ b/string/index.go @@ -213,7 +213,7 @@ func IndexAllIgnoreCaseUnicode(haystack string, needle string, limit int) [][]in // When we have confirmed a match we add it to our total // but adjust the positions to the match and the length of the // needle to ensure the byte count lines up - locs = append(locs, []int{match[0], match[0] + len(toMatch)}) + locs = append(locs, []int{match[0], match[0] + len(string(toMatch))}) if limit > 0 && len(locs) > limit { return locs[:limit] diff --git a/string/index_test.go b/string/index_test.go index 7faf5bd..7c3d6eb 100644 --- a/string/index_test.go +++ b/string/index_test.go @@ -175,7 +175,7 @@ func TestIndexAllIgnoreCaseUnicodeCheckEnd(t *testing.T) { matches := IndexAllIgnoreCaseUnicode("a ſecret a", "secret", -1) if matches[0][0] != 2 || matches[0][1] != 9 { - t.Error("Expected 2 and 7 got", matches[0][0], "and", matches[0][1]) + t.Error("Expected 2 and 9 got", matches[0][0], "and", matches[0][1]) } if "a ſecret a"[matches[0][0]:matches[0][1]] != "ſecret" {