Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fetch: use EOL of os-module #2915

Merged
merged 1 commit into from
Mar 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions lib/web/fetch/file.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
'use strict'

const { EOL } = require('node:os')
const { Blob, File: NativeFile } = require('node:buffer')
const { types } = require('node:util')
const { kState } = require('./symbols')
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 {
Expand Down Expand Up @@ -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
Expand Down
Loading