MCPcopy Index your code
hub / github.com/ZenNotes/zennotes / indexOfFold

Function indexOfFold

apps/server/internal/httpserver/server.go:1080–1106  ·  view source on GitHub ↗
(haystack, needle []byte)

Source from the content-addressed store, hash-verified

1078}
1079
1080func indexOfFold(haystack, needle []byte) int {
1081 n := len(needle)
1082 if n == 0 || n > len(haystack) {
1083 return -1
1084 }
1085 for i := 0; i+n <= len(haystack); i++ {
1086 match := true
1087 for j := 0; j < n; j++ {
1088 a := haystack[i+j]
1089 b := needle[j]
1090 if a >= 'A' && a <= 'Z' {
1091 a += 'a' - 'A'
1092 }
1093 if b >= 'A' && b <= 'Z' {
1094 b += 'a' - 'A'
1095 }
1096 if a != b {
1097 match = false
1098 break
1099 }
1100 }
1101 if match {
1102 return i
1103 }
1104 }
1105 return -1
1106}
1107
1108func copyReadSeeker(w http.ResponseWriter, f fs.File) (int64, error) {
1109 if rs, ok := f.(interface {

Callers 1

injectBasePathHintFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected