fix(strutil): preserve IndexOffset not-found results (#367)

This commit is contained in:
Yusuf Efe authored and GitHub committed 2026-10-23 18:14:24 +08:00
1 parent 34c7e36d29
commit 99ed115de4
2 files changed
+6 -1

No files matched your search

+4 -1
View File
@@ -483,7 +483,10 @@ func IndexOffset(str string, substr string, idxFrom int) int {
return -1
}
return strings.Index(str[idxFrom:], substr) + idxFrom
if index := strings.Index(str[idxFrom:], substr); index >= 0 {
return index + idxFrom
}
return -1
}
// ReplaceWithMap returns a copy of `str`,