buffer: normalize lone "\r" in Blob native line endings · nodejs/node@21e2420 · GitHub
Skip to content

Commit 21e2420

Browse files
watildeaduh95
authored andcommitted
buffer: normalize lone "\r" in Blob native line endings
`new Blob(parts, { endings: 'native' })` failed to normalize a standalone carriage return. The replacement regex only matched `\n` and `\r\n`, so a lone `\r` (and runs such as `\r\r`) were left untouched instead of being converted to the platform's native line ending. The WHATWG "convert line endings to native" algorithm requires `\r`, `\n`, and `\r\n` to all be normalized. Match `\r\n` before a lone `\r` so that CRLF collapses to a single native ending. Refs: https://w3c.github.io/FileAPI/#convert-line-endings-to-native Signed-off-by: Daijiro Wachi <daijiro.wachi@gmail.com> PR-URL: #64115 Refs: https://w3c.github.io/FileAPI/#convert-line-endings-to-native Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Jason Zhang <xzha4350@gmail.com>
1 parent 59af7e0 commit 21e2420

2 files changed

Lines changed: 19 additions & 1 deletion

File tree

lib/internal/blob.js

Lines changed: 1 addition & 1 deletion

test/parallel/test-blob.js

Lines changed: 18 additions & 0 deletions

0 commit comments

Comments
 (0)