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 bengl committed Feb 22, 2022
1 parent 4e2e2cb commit d34ee45
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions doc/api/stream.md
Original file line number Diff line number Diff line change
Expand Up @@ -1532,7 +1532,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 @@ -1545,10 +1545,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 d34ee45

Please sign in to comment.