MCPcopy Index your code
hub / github.com/bootdotdev/bootdev / likelyBinary

Function likelyBinary

checks/http.go:222–231  ·  view source on GitHub ↗
(b []byte)

Source from the content-addressed store, hash-verified

220}
221
222func likelyBinary(b []byte) bool {
223 if len(b) == 0 {
224 return false
225 }
226 if len(b) > 8000 {
227 b = b[:8000]
228 b = trimIncompleteUTF8(b) // in case we broke a multi-byte char
229 }
230 return slices.Contains(b, 0) || !utf8.Valid(b)
231}
232
233func trimIncompleteUTF8(b []byte) []byte {
234 for i := 0; i < 3 && len(b) > 0; i++ {

Callers 1

truncateAndStringifyBodyFunction · 0.85

Calls 1

trimIncompleteUTF8Function · 0.85

Tested by

no test coverage detected