module

Hwaro::Utils::ByteScan

Instance methods

byte_index(haystack : String, needle : String, start : Int32 = 0) : Int32 | Nil

Byte offset of the first occurrence of needle in haystack, or nil.

start is a byte offset. An out-of-range or negative start finds nothing rather than raising — probes run on attacker-shaped content and must not turn a scan into an exception.

Source
includes?(haystack : String, needle : String) : Bool

True when the bytes of needle occur anywhere in haystack.

Equivalent to haystack.includes?(needle) for every needle hwaro probes with (String#includes? answers the same question over the same bytes; only the index it can also return is character-based).

Source