@whatwg-node/node-fetch 0.5.0-alpha-20230522130438-430d828 → 0.5.0-alpha-20230525151330-a086b4b

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/cjs/Blob.js CHANGED
@@ -30,8 +30,8 @@ class PonyfillBlob {
30
30
  constructor(blobParts, options) {
31
31
  this.blobParts = blobParts;
32
32
  this[_a] = 'Blob';
33
- this.type = (options === null || options === void 0 ? void 0 : options.type) || 'application/octet-stream';
34
- this.encoding = (options === null || options === void 0 ? void 0 : options.encoding) || 'utf8';
33
+ this.type = options?.type || 'application/octet-stream';
34
+ this.encoding = options?.encoding || 'utf8';
35
35
  }
36
36
  async buffer() {
37
37
  const bufferChunks = [];
package/cjs/Body.js CHANGED
@@ -134,7 +134,7 @@ class PonyfillBody {
134
134
  }
135
135
  const formDataLimits = {
136
136
  ...this.options.formDataLimits,
137
- ...opts === null || opts === void 0 ? void 0 : opts.formDataLimits,
137
+ ...opts?.formDataLimits,
138
138
  };
139
139
  return new Promise((resolve, reject) => {
140
140
  const bb = (0, busboy_1.default)({
@@ -146,37 +146,37 @@ class PonyfillBody {
146
146
  });
147
147
  bb.on('field', (name, value, { nameTruncated, valueTruncated }) => {
148
148
  if (nameTruncated) {
149
- reject(new Error(`Field name size exceeded: ${formDataLimits === null || formDataLimits === void 0 ? void 0 : formDataLimits.fieldNameSize} bytes`));
149
+ reject(new Error(`Field name size exceeded: ${formDataLimits?.fieldNameSize} bytes`));
150
150
  }
151
151
  if (valueTruncated) {
152
- reject(new Error(`Field value size exceeded: ${formDataLimits === null || formDataLimits === void 0 ? void 0 : formDataLimits.fieldSize} bytes`));
152
+ reject(new Error(`Field value size exceeded: ${formDataLimits?.fieldSize} bytes`));
153
153
  }
154
154
  formData.set(name, value);
155
155
  });
156
156
  bb.on('fieldsLimit', () => {
157
- reject(new Error(`Fields limit exceeded: ${formDataLimits === null || formDataLimits === void 0 ? void 0 : formDataLimits.fields}`));
157
+ reject(new Error(`Fields limit exceeded: ${formDataLimits?.fields}`));
158
158
  });
159
159
  bb.on('file', (name, fileStream, { filename, mimeType }) => {
160
160
  const chunks = [];
161
161
  fileStream.on('limit', () => {
162
- reject(new Error(`File size limit exceeded: ${formDataLimits === null || formDataLimits === void 0 ? void 0 : formDataLimits.fileSize} bytes`));
162
+ reject(new Error(`File size limit exceeded: ${formDataLimits?.fileSize} bytes`));
163
163
  });
164
164
  fileStream.on('data', chunk => {
165
165
  chunks.push(Buffer.from(chunk));
166
166
  });
167
167
  fileStream.on('close', () => {
168
168
  if (fileStream.truncated) {
169
- reject(new Error(`File size limit exceeded: ${formDataLimits === null || formDataLimits === void 0 ? void 0 : formDataLimits.fileSize} bytes`));
169
+ reject(new Error(`File size limit exceeded: ${formDataLimits?.fileSize} bytes`));
170
170
  }
171
171
  const file = new File_js_1.PonyfillFile(chunks, filename, { type: mimeType });
172
172
  formData.set(name, file);
173
173
  });
174
174
  });
175
175
  bb.on('filesLimit', () => {
176
- reject(new Error(`Files limit exceeded: ${formDataLimits === null || formDataLimits === void 0 ? void 0 : formDataLimits.files}`));
176
+ reject(new Error(`Files limit exceeded: ${formDataLimits?.files}`));
177
177
  });
178
178
  bb.on('partsLimit', () => {
179
- reject(new Error(`Parts limit exceeded: ${formDataLimits === null || formDataLimits === void 0 ? void 0 : formDataLimits.parts}`));
179
+ reject(new Error(`Parts limit exceeded: ${formDataLimits?.parts}`));
180
180
  });
181
181
  bb.on('close', () => {
182
182
  resolve(formData);
@@ -184,7 +184,7 @@ class PonyfillBody {
184
184
  bb.on('error', err => {
185
185
  reject(err);
186
186
  });
187
- _body === null || _body === void 0 ? void 0 : _body.readable.pipe(bb);
187
+ _body?.readable.pipe(bb);
188
188
  });
189
189
  }
190
190
  async buffer() {
package/cjs/File.js CHANGED
@@ -7,7 +7,7 @@ class PonyfillFile extends Blob_js_1.PonyfillBlob {
7
7
  super(fileBits, options);
8
8
  this.name = name;
9
9
  this.webkitRelativePath = '';
10
- this.lastModified = (options === null || options === void 0 ? void 0 : options.lastModified) || Date.now();
10
+ this.lastModified = options?.lastModified || Date.now();
11
11
  }
12
12
  }
13
13
  exports.PonyfillFile = PonyfillFile;
package/cjs/FormData.js CHANGED
@@ -1,4 +1,5 @@
1
1
  "use strict";
2
+ var _a;
2
3
  Object.defineProperty(exports, "__esModule", { value: true });
3
4
  exports.getStreamFromFormData = exports.PonyfillFormData = void 0;
4
5
  const File_js_1 = require("./File.js");
@@ -6,6 +7,7 @@ const ReadableStream_js_1 = require("./ReadableStream.js");
6
7
  class PonyfillFormData {
7
8
  constructor() {
8
9
  this.map = new Map();
10
+ this[_a] = 'FormData';
9
11
  Object.defineProperty(this.constructor, 'name', {
10
12
  value: 'FormData',
11
13
  });
@@ -65,12 +67,9 @@ class PonyfillFormData {
65
67
  callback(value, key, this);
66
68
  }
67
69
  }
68
- // undici compat
69
- stream() {
70
- return getStreamFromFormData(this);
71
- }
72
70
  }
73
71
  exports.PonyfillFormData = PonyfillFormData;
72
+ _a = Symbol.toStringTag;
74
73
  function getStreamFromFormData(formData, boundary = '---') {
75
74
  const entries = [];
76
75
  let sentInitialHeader = false;
@@ -90,26 +90,24 @@ class PonyfillReadableStream {
90
90
  }
91
91
  ongoing = true;
92
92
  return Promise.resolve().then(async () => {
93
- var _a, _b;
94
93
  if (!started) {
95
94
  const controller = createController(desiredSize, this);
96
95
  started = true;
97
- await ((_a = underlyingSource === null || underlyingSource === void 0 ? void 0 : underlyingSource.start) === null || _a === void 0 ? void 0 : _a.call(underlyingSource, controller));
96
+ await underlyingSource?.start?.(controller);
98
97
  controller._flush();
99
98
  if (controller._closed) {
100
99
  return;
101
100
  }
102
101
  }
103
102
  const controller = createController(desiredSize, this);
104
- await ((_b = underlyingSource === null || underlyingSource === void 0 ? void 0 : underlyingSource.pull) === null || _b === void 0 ? void 0 : _b.call(underlyingSource, controller));
103
+ await underlyingSource?.pull?.(controller);
105
104
  controller._flush();
106
105
  ongoing = false;
107
106
  });
108
107
  },
109
108
  async destroy(err, callback) {
110
- var _a;
111
109
  try {
112
- await ((_a = underlyingSource === null || underlyingSource === void 0 ? void 0 : underlyingSource.cancel) === null || _a === void 0 ? void 0 : _a.call(underlyingSource, err));
110
+ await underlyingSource?.cancel?.(err);
113
111
  callback(null);
114
112
  }
115
113
  catch (err) {
@@ -131,13 +129,11 @@ class PonyfillReadableStream {
131
129
  return iterator.next();
132
130
  },
133
131
  releaseLock: () => {
134
- var _a;
135
- (_a = iterator.return) === null || _a === void 0 ? void 0 : _a.call(iterator);
132
+ iterator.return?.();
136
133
  this.locked = false;
137
134
  },
138
135
  cancel: async (reason) => {
139
- var _a;
140
- await ((_a = iterator.return) === null || _a === void 0 ? void 0 : _a.call(iterator, reason));
136
+ await iterator.return?.(reason);
141
137
  this.locked = false;
142
138
  },
143
139
  closed: new Promise((resolve, reject) => {
package/cjs/Request.js CHANGED
@@ -9,7 +9,6 @@ function isRequest(input) {
9
9
  }
10
10
  class PonyfillRequest extends Body_js_1.PonyfillBody {
11
11
  constructor(input, options) {
12
- var _a;
13
12
  let url;
14
13
  let bodyInit = null;
15
14
  let requestInit;
@@ -31,18 +30,18 @@ class PonyfillRequest extends Body_js_1.PonyfillBody {
31
30
  super(bodyInit, options);
32
31
  this.destination = '';
33
32
  this.priority = 'auto';
34
- this.cache = (requestInit === null || requestInit === void 0 ? void 0 : requestInit.cache) || 'default';
35
- this.credentials = (requestInit === null || requestInit === void 0 ? void 0 : requestInit.credentials) || 'same-origin';
36
- this.headers = new Headers_js_1.PonyfillHeaders(requestInit === null || requestInit === void 0 ? void 0 : requestInit.headers);
37
- this.integrity = (requestInit === null || requestInit === void 0 ? void 0 : requestInit.integrity) || '';
38
- this.keepalive = (requestInit === null || requestInit === void 0 ? void 0 : requestInit.keepalive) != null ? requestInit === null || requestInit === void 0 ? void 0 : requestInit.keepalive : false;
39
- this.method = ((_a = requestInit === null || requestInit === void 0 ? void 0 : requestInit.method) === null || _a === void 0 ? void 0 : _a.toUpperCase()) || 'GET';
40
- this.mode = (requestInit === null || requestInit === void 0 ? void 0 : requestInit.mode) || 'cors';
41
- this.redirect = (requestInit === null || requestInit === void 0 ? void 0 : requestInit.redirect) || 'follow';
42
- this.referrer = (requestInit === null || requestInit === void 0 ? void 0 : requestInit.referrer) || 'about:client';
43
- this.referrerPolicy = (requestInit === null || requestInit === void 0 ? void 0 : requestInit.referrerPolicy) || 'no-referrer';
44
- this.signal = (requestInit === null || requestInit === void 0 ? void 0 : requestInit.signal) || new AbortController().signal;
45
- this.headersSerializer = (requestInit === null || requestInit === void 0 ? void 0 : requestInit.headersSerializer) || utils_js_1.getHeadersObj;
33
+ this.cache = requestInit?.cache || 'default';
34
+ this.credentials = requestInit?.credentials || 'same-origin';
35
+ this.headers = new Headers_js_1.PonyfillHeaders(requestInit?.headers);
36
+ this.integrity = requestInit?.integrity || '';
37
+ this.keepalive = requestInit?.keepalive != null ? requestInit?.keepalive : false;
38
+ this.method = requestInit?.method?.toUpperCase() || 'GET';
39
+ this.mode = requestInit?.mode || 'cors';
40
+ this.redirect = requestInit?.redirect || 'follow';
41
+ this.referrer = requestInit?.referrer || 'about:client';
42
+ this.referrerPolicy = requestInit?.referrerPolicy || 'no-referrer';
43
+ this.signal = requestInit?.signal || new AbortController().signal;
44
+ this.headersSerializer = requestInit?.headersSerializer || utils_js_1.getHeadersObj;
46
45
  this.url = url || '';
47
46
  const contentTypeInHeaders = this.headers.get('content-type');
48
47
  if (!contentTypeInHeaders) {
package/cjs/Response.js CHANGED
@@ -68,7 +68,7 @@ class PonyfillResponse extends Body_js_1.PonyfillBody {
68
68
  ...init,
69
69
  headers: {
70
70
  'Content-Type': 'application/json',
71
- ...init === null || init === void 0 ? void 0 : init.headers,
71
+ ...init?.headers,
72
72
  },
73
73
  });
74
74
  }
package/cjs/URL.js CHANGED
@@ -32,15 +32,13 @@ class PonyfillURL extends fast_url_parser_1.default {
32
32
  return this._searchParams;
33
33
  }
34
34
  get username() {
35
- var _a;
36
- return ((_a = this.auth) === null || _a === void 0 ? void 0 : _a.split(':')[0]) || '';
35
+ return this.auth?.split(':')[0] || '';
37
36
  }
38
37
  set username(value) {
39
38
  this.auth = `${value}:${this.password}`;
40
39
  }
41
40
  get password() {
42
- var _a;
43
- return ((_a = this.auth) === null || _a === void 0 ? void 0 : _a.split(':')[1]) || '';
41
+ return this.auth?.split(':')[1] || '';
44
42
  }
45
43
  set password(value) {
46
44
  this.auth = `${this.username}:${value}`;
package/cjs/fetch.js CHANGED
@@ -53,14 +53,17 @@ async function fetchPonyfill(info, init) {
53
53
  return response;
54
54
  }
55
55
  const requestBody = (fetchRequest['bodyInit'] != null
56
- ? fetchRequest['bodyInit'] :
57
- fetchRequest.body != null
56
+ ? fetchRequest['bodyInit']
57
+ : fetchRequest.body != null
58
58
  ? 'pipe' in fetchRequest.body
59
59
  ? fetchRequest.body
60
60
  : stream_1.Readable.from(fetchRequest.body)
61
61
  : null);
62
62
  const headersSerializer = fetchRequest.headersSerializer || utils_js_1.getHeadersObj;
63
63
  const nodeHeaders = headersSerializer(fetchRequest.headers);
64
+ if (requestBody?.[Symbol.toStringTag] === 'FormData') {
65
+ delete nodeHeaders['content-type'];
66
+ }
64
67
  const undiciData = await (0, undici_1.request)(fetchRequest.url, {
65
68
  method: fetchRequest.method,
66
69
  headers: nodeHeaders,
package/esm/Blob.js CHANGED
@@ -27,8 +27,8 @@ export class PonyfillBlob {
27
27
  constructor(blobParts, options) {
28
28
  this.blobParts = blobParts;
29
29
  this[_a] = 'Blob';
30
- this.type = (options === null || options === void 0 ? void 0 : options.type) || 'application/octet-stream';
31
- this.encoding = (options === null || options === void 0 ? void 0 : options.encoding) || 'utf8';
30
+ this.type = options?.type || 'application/octet-stream';
31
+ this.encoding = options?.encoding || 'utf8';
32
32
  }
33
33
  async buffer() {
34
34
  const bufferChunks = [];
package/esm/Body.js CHANGED
@@ -130,7 +130,7 @@ export class PonyfillBody {
130
130
  }
131
131
  const formDataLimits = {
132
132
  ...this.options.formDataLimits,
133
- ...opts === null || opts === void 0 ? void 0 : opts.formDataLimits,
133
+ ...opts?.formDataLimits,
134
134
  };
135
135
  return new Promise((resolve, reject) => {
136
136
  const bb = busboy({
@@ -142,37 +142,37 @@ export class PonyfillBody {
142
142
  });
143
143
  bb.on('field', (name, value, { nameTruncated, valueTruncated }) => {
144
144
  if (nameTruncated) {
145
- reject(new Error(`Field name size exceeded: ${formDataLimits === null || formDataLimits === void 0 ? void 0 : formDataLimits.fieldNameSize} bytes`));
145
+ reject(new Error(`Field name size exceeded: ${formDataLimits?.fieldNameSize} bytes`));
146
146
  }
147
147
  if (valueTruncated) {
148
- reject(new Error(`Field value size exceeded: ${formDataLimits === null || formDataLimits === void 0 ? void 0 : formDataLimits.fieldSize} bytes`));
148
+ reject(new Error(`Field value size exceeded: ${formDataLimits?.fieldSize} bytes`));
149
149
  }
150
150
  formData.set(name, value);
151
151
  });
152
152
  bb.on('fieldsLimit', () => {
153
- reject(new Error(`Fields limit exceeded: ${formDataLimits === null || formDataLimits === void 0 ? void 0 : formDataLimits.fields}`));
153
+ reject(new Error(`Fields limit exceeded: ${formDataLimits?.fields}`));
154
154
  });
155
155
  bb.on('file', (name, fileStream, { filename, mimeType }) => {
156
156
  const chunks = [];
157
157
  fileStream.on('limit', () => {
158
- reject(new Error(`File size limit exceeded: ${formDataLimits === null || formDataLimits === void 0 ? void 0 : formDataLimits.fileSize} bytes`));
158
+ reject(new Error(`File size limit exceeded: ${formDataLimits?.fileSize} bytes`));
159
159
  });
160
160
  fileStream.on('data', chunk => {
161
161
  chunks.push(Buffer.from(chunk));
162
162
  });
163
163
  fileStream.on('close', () => {
164
164
  if (fileStream.truncated) {
165
- reject(new Error(`File size limit exceeded: ${formDataLimits === null || formDataLimits === void 0 ? void 0 : formDataLimits.fileSize} bytes`));
165
+ reject(new Error(`File size limit exceeded: ${formDataLimits?.fileSize} bytes`));
166
166
  }
167
167
  const file = new PonyfillFile(chunks, filename, { type: mimeType });
168
168
  formData.set(name, file);
169
169
  });
170
170
  });
171
171
  bb.on('filesLimit', () => {
172
- reject(new Error(`Files limit exceeded: ${formDataLimits === null || formDataLimits === void 0 ? void 0 : formDataLimits.files}`));
172
+ reject(new Error(`Files limit exceeded: ${formDataLimits?.files}`));
173
173
  });
174
174
  bb.on('partsLimit', () => {
175
- reject(new Error(`Parts limit exceeded: ${formDataLimits === null || formDataLimits === void 0 ? void 0 : formDataLimits.parts}`));
175
+ reject(new Error(`Parts limit exceeded: ${formDataLimits?.parts}`));
176
176
  });
177
177
  bb.on('close', () => {
178
178
  resolve(formData);
@@ -180,7 +180,7 @@ export class PonyfillBody {
180
180
  bb.on('error', err => {
181
181
  reject(err);
182
182
  });
183
- _body === null || _body === void 0 ? void 0 : _body.readable.pipe(bb);
183
+ _body?.readable.pipe(bb);
184
184
  });
185
185
  }
186
186
  async buffer() {
package/esm/File.js CHANGED
@@ -4,6 +4,6 @@ export class PonyfillFile extends PonyfillBlob {
4
4
  super(fileBits, options);
5
5
  this.name = name;
6
6
  this.webkitRelativePath = '';
7
- this.lastModified = (options === null || options === void 0 ? void 0 : options.lastModified) || Date.now();
7
+ this.lastModified = options?.lastModified || Date.now();
8
8
  }
9
9
  }
package/esm/FormData.js CHANGED
@@ -1,8 +1,10 @@
1
+ var _a;
1
2
  import { PonyfillFile } from './File.js';
2
3
  import { PonyfillReadableStream } from './ReadableStream.js';
3
4
  export class PonyfillFormData {
4
5
  constructor() {
5
6
  this.map = new Map();
7
+ this[_a] = 'FormData';
6
8
  Object.defineProperty(this.constructor, 'name', {
7
9
  value: 'FormData',
8
10
  });
@@ -62,11 +64,8 @@ export class PonyfillFormData {
62
64
  callback(value, key, this);
63
65
  }
64
66
  }
65
- // undici compat
66
- stream() {
67
- return getStreamFromFormData(this);
68
- }
69
67
  }
68
+ _a = Symbol.toStringTag;
70
69
  export function getStreamFromFormData(formData, boundary = '---') {
71
70
  const entries = [];
72
71
  let sentInitialHeader = false;
@@ -87,26 +87,24 @@ export class PonyfillReadableStream {
87
87
  }
88
88
  ongoing = true;
89
89
  return Promise.resolve().then(async () => {
90
- var _a, _b;
91
90
  if (!started) {
92
91
  const controller = createController(desiredSize, this);
93
92
  started = true;
94
- await ((_a = underlyingSource === null || underlyingSource === void 0 ? void 0 : underlyingSource.start) === null || _a === void 0 ? void 0 : _a.call(underlyingSource, controller));
93
+ await underlyingSource?.start?.(controller);
95
94
  controller._flush();
96
95
  if (controller._closed) {
97
96
  return;
98
97
  }
99
98
  }
100
99
  const controller = createController(desiredSize, this);
101
- await ((_b = underlyingSource === null || underlyingSource === void 0 ? void 0 : underlyingSource.pull) === null || _b === void 0 ? void 0 : _b.call(underlyingSource, controller));
100
+ await underlyingSource?.pull?.(controller);
102
101
  controller._flush();
103
102
  ongoing = false;
104
103
  });
105
104
  },
106
105
  async destroy(err, callback) {
107
- var _a;
108
106
  try {
109
- await ((_a = underlyingSource === null || underlyingSource === void 0 ? void 0 : underlyingSource.cancel) === null || _a === void 0 ? void 0 : _a.call(underlyingSource, err));
107
+ await underlyingSource?.cancel?.(err);
110
108
  callback(null);
111
109
  }
112
110
  catch (err) {
@@ -128,13 +126,11 @@ export class PonyfillReadableStream {
128
126
  return iterator.next();
129
127
  },
130
128
  releaseLock: () => {
131
- var _a;
132
- (_a = iterator.return) === null || _a === void 0 ? void 0 : _a.call(iterator);
129
+ iterator.return?.();
133
130
  this.locked = false;
134
131
  },
135
132
  cancel: async (reason) => {
136
- var _a;
137
- await ((_a = iterator.return) === null || _a === void 0 ? void 0 : _a.call(iterator, reason));
133
+ await iterator.return?.(reason);
138
134
  this.locked = false;
139
135
  },
140
136
  closed: new Promise((resolve, reject) => {
package/esm/Request.js CHANGED
@@ -6,7 +6,6 @@ function isRequest(input) {
6
6
  }
7
7
  export class PonyfillRequest extends PonyfillBody {
8
8
  constructor(input, options) {
9
- var _a;
10
9
  let url;
11
10
  let bodyInit = null;
12
11
  let requestInit;
@@ -28,18 +27,18 @@ export class PonyfillRequest extends PonyfillBody {
28
27
  super(bodyInit, options);
29
28
  this.destination = '';
30
29
  this.priority = 'auto';
31
- this.cache = (requestInit === null || requestInit === void 0 ? void 0 : requestInit.cache) || 'default';
32
- this.credentials = (requestInit === null || requestInit === void 0 ? void 0 : requestInit.credentials) || 'same-origin';
33
- this.headers = new PonyfillHeaders(requestInit === null || requestInit === void 0 ? void 0 : requestInit.headers);
34
- this.integrity = (requestInit === null || requestInit === void 0 ? void 0 : requestInit.integrity) || '';
35
- this.keepalive = (requestInit === null || requestInit === void 0 ? void 0 : requestInit.keepalive) != null ? requestInit === null || requestInit === void 0 ? void 0 : requestInit.keepalive : false;
36
- this.method = ((_a = requestInit === null || requestInit === void 0 ? void 0 : requestInit.method) === null || _a === void 0 ? void 0 : _a.toUpperCase()) || 'GET';
37
- this.mode = (requestInit === null || requestInit === void 0 ? void 0 : requestInit.mode) || 'cors';
38
- this.redirect = (requestInit === null || requestInit === void 0 ? void 0 : requestInit.redirect) || 'follow';
39
- this.referrer = (requestInit === null || requestInit === void 0 ? void 0 : requestInit.referrer) || 'about:client';
40
- this.referrerPolicy = (requestInit === null || requestInit === void 0 ? void 0 : requestInit.referrerPolicy) || 'no-referrer';
41
- this.signal = (requestInit === null || requestInit === void 0 ? void 0 : requestInit.signal) || new AbortController().signal;
42
- this.headersSerializer = (requestInit === null || requestInit === void 0 ? void 0 : requestInit.headersSerializer) || getHeadersObj;
30
+ this.cache = requestInit?.cache || 'default';
31
+ this.credentials = requestInit?.credentials || 'same-origin';
32
+ this.headers = new PonyfillHeaders(requestInit?.headers);
33
+ this.integrity = requestInit?.integrity || '';
34
+ this.keepalive = requestInit?.keepalive != null ? requestInit?.keepalive : false;
35
+ this.method = requestInit?.method?.toUpperCase() || 'GET';
36
+ this.mode = requestInit?.mode || 'cors';
37
+ this.redirect = requestInit?.redirect || 'follow';
38
+ this.referrer = requestInit?.referrer || 'about:client';
39
+ this.referrerPolicy = requestInit?.referrerPolicy || 'no-referrer';
40
+ this.signal = requestInit?.signal || new AbortController().signal;
41
+ this.headersSerializer = requestInit?.headersSerializer || getHeadersObj;
43
42
  this.url = url || '';
44
43
  const contentTypeInHeaders = this.headers.get('content-type');
45
44
  if (!contentTypeInHeaders) {
package/esm/Response.js CHANGED
@@ -65,7 +65,7 @@ export class PonyfillResponse extends PonyfillBody {
65
65
  ...init,
66
66
  headers: {
67
67
  'Content-Type': 'application/json',
68
- ...init === null || init === void 0 ? void 0 : init.headers,
68
+ ...init?.headers,
69
69
  },
70
70
  });
71
71
  }
package/esm/URL.js CHANGED
@@ -28,15 +28,13 @@ export class PonyfillURL extends FastUrl {
28
28
  return this._searchParams;
29
29
  }
30
30
  get username() {
31
- var _a;
32
- return ((_a = this.auth) === null || _a === void 0 ? void 0 : _a.split(':')[0]) || '';
31
+ return this.auth?.split(':')[0] || '';
33
32
  }
34
33
  set username(value) {
35
34
  this.auth = `${value}:${this.password}`;
36
35
  }
37
36
  get password() {
38
- var _a;
39
- return ((_a = this.auth) === null || _a === void 0 ? void 0 : _a.split(':')[1]) || '';
37
+ return this.auth?.split(':')[1] || '';
40
38
  }
41
39
  set password(value) {
42
40
  this.auth = `${this.username}:${value}`;
package/esm/fetch.js CHANGED
@@ -50,14 +50,17 @@ export async function fetchPonyfill(info, init) {
50
50
  return response;
51
51
  }
52
52
  const requestBody = (fetchRequest['bodyInit'] != null
53
- ? fetchRequest['bodyInit'] :
54
- fetchRequest.body != null
53
+ ? fetchRequest['bodyInit']
54
+ : fetchRequest.body != null
55
55
  ? 'pipe' in fetchRequest.body
56
56
  ? fetchRequest.body
57
57
  : Readable.from(fetchRequest.body)
58
58
  : null);
59
59
  const headersSerializer = fetchRequest.headersSerializer || getHeadersObj;
60
60
  const nodeHeaders = headersSerializer(fetchRequest.headers);
61
+ if (requestBody?.[Symbol.toStringTag] === 'FormData') {
62
+ delete nodeHeaders['content-type'];
63
+ }
61
64
  const undiciData = await request(fetchRequest.url, {
62
65
  method: fetchRequest.method,
63
66
  headers: nodeHeaders,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@whatwg-node/node-fetch",
3
- "version": "0.5.0-alpha-20230522130438-430d828",
3
+ "version": "0.5.0-alpha-20230525151330-a086b4b",
4
4
  "description": "Fetch API implementation for Node",
5
5
  "sideEffects": false,
6
6
  "dependencies": {
@@ -8,7 +8,8 @@
8
8
  "busboy": "^1.6.0",
9
9
  "fast-querystring": "^1.1.1",
10
10
  "fast-url-parser": "^1.1.3",
11
- "tslib": "^2.3.1"
11
+ "tslib": "^2.3.1",
12
+ "undici": "^5.22.1"
12
13
  },
13
14
  "repository": {
14
15
  "type": "git",
@@ -14,6 +14,6 @@ export declare class PonyfillFormData implements FormData {
14
14
  keys(): IterableIterator<string>;
15
15
  values(): IterableIterator<FormDataEntryValue>;
16
16
  forEach(callback: (value: FormDataEntryValue, key: string, parent: this) => void): void;
17
- stream(): PonyfillReadableStream<Uint8Array>;
17
+ [Symbol.toStringTag]: string;
18
18
  }
19
19
  export declare function getStreamFromFormData(formData: FormData, boundary?: string): PonyfillReadableStream<Uint8Array>;
@@ -14,6 +14,6 @@ export declare class PonyfillFormData implements FormData {
14
14
  keys(): IterableIterator<string>;
15
15
  values(): IterableIterator<FormDataEntryValue>;
16
16
  forEach(callback: (value: FormDataEntryValue, key: string, parent: this) => void): void;
17
- stream(): PonyfillReadableStream<Uint8Array>;
17
+ [Symbol.toStringTag]: string;
18
18
  }
19
19
  export declare function getStreamFromFormData(formData: FormData, boundary?: string): PonyfillReadableStream<Uint8Array>;