diff options
author | Iván Canales <kanales@users.noreply.github.com> | 2020-12-05 17:41:16 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-05 17:41:16 +0100 |
commit | c10280214e5e15fb31b83368082916b9f25470f9 (patch) | |
tree | c0ca3b76a688c625629f23e8e77a48f1dbfbbef8 /std/io/bufio.ts | |
parent | 2d5c742cf608b2ce0c5a51fb80f34cfd8ffd2e83 (diff) |
fix(std/bufio): Remove '\r' at the end of Windows lines (#8447)
Co-authored-by: Nayeem Rahman <nayeemrmn99@gmail.com>
Diffstat (limited to 'std/io/bufio.ts')
-rw-r--r-- | std/io/bufio.ts | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/std/io/bufio.ts b/std/io/bufio.ts index 954fc5eee..df3ecb002 100644 --- a/std/io/bufio.ts +++ b/std/io/bufio.ts @@ -706,5 +706,13 @@ export async function* readStringDelim( export async function* readLines( reader: Reader, ): AsyncIterableIterator<string> { - yield* readStringDelim(reader, "\n"); + for await (let chunk of readStringDelim(reader, "\n")) { + // Finding a CR at the end of the line is evidence of a + // "\r\n" at the end of the line. The "\r" part should be + // removed too. + if (chunk.endsWith("\r")) { + chunk = chunk.slice(0, -1); + } + yield chunk; + } } |