-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
readline: fix detection of carriage return
Fixes: #45992 PR-URL: #46306 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Yagiz Nizipli <[email protected]>
- Loading branch information
Showing
3 changed files
with
24 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 0 additions & 42 deletions
42
test/known_issues/test-readline-big-file-carriage-return.js
This file was deleted.
Oops, something went wrong.
23 changes: 23 additions & 0 deletions
23
test/parallel/test-readline-carriage-return-between-chunks.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
'use strict'; | ||
|
||
const common = require('../common'); | ||
|
||
const assert = require('node:assert'); | ||
const readline = require('node:readline'); | ||
const { Readable } = require('node:stream'); | ||
|
||
|
||
const input = Readable.from((function*() { | ||
yield 'a\nb'; | ||
yield '\r\n'; | ||
})()); | ||
const rl = readline.createInterface({ input, crlfDelay: Infinity }); | ||
let carriageReturns = 0; | ||
|
||
rl.on('line', (line) => { | ||
if (line.includes('\r')) carriageReturns++; | ||
}); | ||
|
||
rl.on('close', common.mustCall(() => { | ||
assert.strictEqual(carriageReturns, 0); | ||
})); |