Skip to content

Commit

Permalink
doc: fix bug in readable.unshift code example
Browse files Browse the repository at this point in the history
PR-URL: #41944
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Mestery <mestery@protonmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
  • Loading branch information
meixg authored and danielleadams committed Apr 24, 2022
1 parent db4a3dc commit d77db88
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions doc/api/stream.md
Expand Up @@ -1528,7 +1528,7 @@ function parseHeader(stream, callback) {
let chunk;
while (null !== (chunk = stream.read())) {
const str = decoder.write(chunk);
if (str.match(/\n\n/)) {
if (str.includes('\n\n')) {
// Found the header boundary.
const split = str.split(/\n\n/);
header += split.shift();
Expand All @@ -1541,10 +1541,10 @@ function parseHeader(stream, callback) {
stream.unshift(buf);
// Now the body of the message can be read from the stream.
callback(null, header, stream);
} else {
// Still reading the header.
header += str;
return;
}
// Still reading the header.
header += str;
}
}
}
Expand Down

0 comments on commit d77db88

Please sign in to comment.