Skip to content

Commit 4c0ad1c

Browse files
meixgbengl
authored andcommitted
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 2b329da commit 4c0ad1c

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

doc/api/stream.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -1532,7 +1532,7 @@ function parseHeader(stream, callback) {
15321532
let chunk;
15331533
while (null !== (chunk = stream.read())) {
15341534
const str = decoder.write(chunk);
1535-
if (str.match(/\n\n/)) {
1535+
if (str.includes('\n\n')) {
15361536
// Found the header boundary.
15371537
const split = str.split(/\n\n/);
15381538
header += split.shift();
@@ -1545,10 +1545,10 @@ function parseHeader(stream, callback) {
15451545
stream.unshift(buf);
15461546
// Now the body of the message can be read from the stream.
15471547
callback(null, header, stream);
1548-
} else {
1549-
// Still reading the header.
1550-
header += str;
1548+
return;
15511549
}
1550+
// Still reading the header.
1551+
header += str;
15521552
}
15531553
}
15541554
}

0 commit comments

Comments
 (0)