Skip to content

Commit ee38bbd

Browse files
authored
doc: fix bug in readable.unshift code example
PR-URL: #41944 Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Mestery <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
1 parent d17be0f commit ee38bbd

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

doc/api/stream.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1586,7 +1586,7 @@ function parseHeader(stream, callback) {
15861586
let chunk;
15871587
while (null !== (chunk = stream.read())) {
15881588
const str = decoder.write(chunk);
1589-
if (str.match(/\n\n/)) {
1589+
if (str.includes('\n\n')) {
15901590
// Found the header boundary.
15911591
const split = str.split(/\n\n/);
15921592
header += split.shift();
@@ -1599,10 +1599,10 @@ function parseHeader(stream, callback) {
15991599
stream.unshift(buf);
16001600
// Now the body of the message can be read from the stream.
16011601
callback(null, header, stream);
1602-
} else {
1603-
// Still reading the header.
1604-
header += str;
1602+
return;
16051603
}
1604+
// Still reading the header.
1605+
header += str;
16061606
}
16071607
}
16081608
}

0 commit comments

Comments
 (0)