Skip to content

Commit d77db88

Browse files
meixgdanielleadams
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 db4a3dc commit d77db88

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
@@ -1528,7 +1528,7 @@ function parseHeader(stream, callback) {
15281528
let chunk;
15291529
while (null !== (chunk = stream.read())) {
15301530
const str = decoder.write(chunk);
1531-
if (str.match(/\n\n/)) {
1531+
if (str.includes('\n\n')) {
15321532
// Found the header boundary.
15331533
const split = str.split(/\n\n/);
15341534
header += split.shift();
@@ -1541,10 +1541,10 @@ function parseHeader(stream, callback) {
15411541
stream.unshift(buf);
15421542
// Now the body of the message can be read from the stream.
15431543
callback(null, header, stream);
1544-
} else {
1545-
// Still reading the header.
1546-
header += str;
1544+
return;
15471545
}
1546+
// Still reading the header.
1547+
header += str;
15481548
}
15491549
}
15501550
}

0 commit comments

Comments
 (0)