Skip to content

Commit

Permalink
lower lookbehind length
Browse files Browse the repository at this point in the history
  • Loading branch information
gurgunday committed Nov 30, 2024
1 parent 67b2cbb commit f61b417
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion deps/streamsearch/sbmh.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ function SBMH (needle) {
this._needle = needle
this._bufpos = 0

this._lookbehind = Buffer.alloc(needleLength)
this._lookbehind = Buffer.alloc(needleLength - 1)

// Populate occurrence table with analysis of the needle,
// ignoring last letter.
Expand Down
8 changes: 4 additions & 4 deletions test/streamsearch.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ test('streamsearch', async t => {

const expected = [
[false, Buffer.from('bar\r'), 0, 3],
[false, Buffer.from('\r\0\0'), 0, 1],
[false, Buffer.from('\r\0'), 0, 1],
[false, Buffer.from('\n\r\nhello'), 0, 8]
]
const needle = '\r\n\n'
Expand Down Expand Up @@ -339,7 +339,7 @@ test('streamsearch', async t => {
t.plan(13)

const expected = [
[false, Buffer.from('\n\n\0'), 0, 1],
[false, Buffer.from('\n\n'), 0, 1],
[true, undefined, undefined, undefined],
[false, Buffer.from('\r\nhello'), 1, 7]
]
Expand Down Expand Up @@ -374,8 +374,8 @@ test('streamsearch', async t => {

const expected = [
[false, Buffer.from('bar\r'), 0, 3],
[false, Buffer.from('\r\n\0'), 0, 2],
[false, Buffer.from('\r\n\0'), 0, 1],
[false, Buffer.from('\r\n'), 0, 2],
[false, Buffer.from('\r\n'), 0, 1],
[false, Buffer.from('hello'), 0, 5]
]
const needle = '\r\n\n'
Expand Down

0 comments on commit f61b417

Please sign in to comment.