From 7bf35a2a601fe3e607eee77e9402c36d319fdcf5 Mon Sep 17 00:00:00 2001 From: uzlopak Date: Sun, 3 Mar 2024 16:52:41 +0100 Subject: [PATCH] fetch: use EOL of os-module --- lib/web/fetch/file.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/web/fetch/file.js b/lib/web/fetch/file.js index e00b58cdb58..3cb4eebb3e0 100644 --- a/lib/web/fetch/file.js +++ b/lib/web/fetch/file.js @@ -1,5 +1,6 @@ 'use strict' +const { EOL } = require('node:os') const { Blob, File: NativeFile } = require('node:buffer') const { types } = require('node:util') const { kState } = require('./symbols') @@ -7,6 +8,7 @@ const { isBlobLike } = require('./util') const { webidl } = require('./webidl') const { parseMIMEType, serializeAMimeType } = require('./data-url') const { kEnumerableProperty } = require('../../core/util') + const encoder = new TextEncoder() class File extends Blob { @@ -307,17 +309,14 @@ function processBlobParts (parts, options) { */ function convertLineEndingsNative (s) { // 1. Let native line ending be be the code point U+000A LF. - let nativeLineEnding = '\n' - // 2. If the underlying platform’s conventions are to // represent newlines as a carriage return and line feed // sequence, set native line ending to the code point // U+000D CR followed by the code point U+000A LF. - if (process.platform === 'win32') { - nativeLineEnding = '\r\n' - } + // NOTE: We are using the native line ending for the current + // platform, provided by node's os module. - return s.replace(/\r?\n/g, nativeLineEnding) + return s.replace(/\r?\n/g, EOL) } // If this function is moved to ./util.js, some tools (such as