New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@whatwg-node/node-fetch

Package Overview
Dependencies
Maintainers
1
Versions
640
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@whatwg-node/node-fetch - npm Package Compare versions

Comparing version 0.4.0-alpha-20230515125426-a472464 to 0.4.0-alpha-20230515131253-e1eec20

cjs/AbortError.js

47

cjs/fetch.js

@@ -10,2 +10,3 @@ "use strict";

const zlib_1 = require("zlib");
const AbortError_js_1 = require("./AbortError.js");
const Blob_js_1 = require("./Blob.js");

@@ -21,2 +22,22 @@ const Request_js_1 = require("./Request.js");

}
function getResponseForDataUri(url) {
const [mimeType = 'text/plain', ...datas] = url.pathname.split(',');
const data = decodeURIComponent(datas.join(','));
if (mimeType.endsWith(BASE64_SUFFIX)) {
const buffer = Buffer.from(data, 'base64url');
const realMimeType = mimeType.slice(0, -BASE64_SUFFIX.length);
const file = new Blob_js_1.PonyfillBlob([buffer], { type: realMimeType });
return new Response_js_1.PonyfillResponse(file, {
status: 200,
statusText: 'OK',
});
}
return new Response_js_1.PonyfillResponse(data, {
status: 200,
statusText: 'OK',
headers: {
'content-type': mimeType,
},
});
}
function getRequestFnForProtocol(protocol) {

@@ -42,22 +63,3 @@ switch (protocol) {

if (url.protocol === 'data:') {
const [mimeType = 'text/plain', ...datas] = url.pathname.split(',');
const data = decodeURIComponent(datas.join(','));
if (mimeType.endsWith(BASE64_SUFFIX)) {
const buffer = Buffer.from(data, 'base64url');
const realMimeType = mimeType.slice(0, -BASE64_SUFFIX.length);
const file = new Blob_js_1.PonyfillBlob([buffer], { type: realMimeType });
const response = new Response_js_1.PonyfillResponse(file, {
status: 200,
statusText: 'OK',
});
resolve(response);
return;
}
const response = new Response_js_1.PonyfillResponse(data, {
status: 200,
statusText: 'OK',
headers: {
'content-type': mimeType,
},
});
const response = getResponseForDataUri(url);
resolve(response);

@@ -80,3 +82,2 @@ return;

const nodeRequest = requestFn(fetchRequest.url, {
// signal: fetchRequest.signal will be added when v14 reaches EOL
method: fetchRequest.method,

@@ -129,2 +130,6 @@ headers: nodeHeaders,

});
// TODO: will be removed after v16 reaches EOL
nodeRequest.once('abort', (reason) => {
reject(new AbortError_js_1.PonyfillAbortError(reason));
});
nodeRequest.once('error', reject);

@@ -131,0 +136,0 @@ if (nodeReadable) {

@@ -7,2 +7,3 @@ import { createReadStream } from 'fs';

import { createBrotliDecompress, createGunzip, createInflate } from 'zlib';
import { PonyfillAbortError } from './AbortError.js';
import { PonyfillBlob } from './Blob.js';

@@ -18,2 +19,22 @@ import { PonyfillRequest } from './Request.js';

}
function getResponseForDataUri(url) {
const [mimeType = 'text/plain', ...datas] = url.pathname.split(',');
const data = decodeURIComponent(datas.join(','));
if (mimeType.endsWith(BASE64_SUFFIX)) {
const buffer = Buffer.from(data, 'base64url');
const realMimeType = mimeType.slice(0, -BASE64_SUFFIX.length);
const file = new PonyfillBlob([buffer], { type: realMimeType });
return new PonyfillResponse(file, {
status: 200,
statusText: 'OK',
});
}
return new PonyfillResponse(data, {
status: 200,
statusText: 'OK',
headers: {
'content-type': mimeType,
},
});
}
function getRequestFnForProtocol(protocol) {

@@ -39,22 +60,3 @@ switch (protocol) {

if (url.protocol === 'data:') {
const [mimeType = 'text/plain', ...datas] = url.pathname.split(',');
const data = decodeURIComponent(datas.join(','));
if (mimeType.endsWith(BASE64_SUFFIX)) {
const buffer = Buffer.from(data, 'base64url');
const realMimeType = mimeType.slice(0, -BASE64_SUFFIX.length);
const file = new PonyfillBlob([buffer], { type: realMimeType });
const response = new PonyfillResponse(file, {
status: 200,
statusText: 'OK',
});
resolve(response);
return;
}
const response = new PonyfillResponse(data, {
status: 200,
statusText: 'OK',
headers: {
'content-type': mimeType,
},
});
const response = getResponseForDataUri(url);
resolve(response);

@@ -77,3 +79,2 @@ return;

const nodeRequest = requestFn(fetchRequest.url, {
// signal: fetchRequest.signal will be added when v14 reaches EOL
method: fetchRequest.method,

@@ -126,2 +127,6 @@ headers: nodeHeaders,

});
// TODO: will be removed after v16 reaches EOL
nodeRequest.once('abort', (reason) => {
reject(new PonyfillAbortError(reason));
});
nodeRequest.once('error', reject);

@@ -128,0 +133,0 @@ if (nodeReadable) {

{
"name": "@whatwg-node/node-fetch",
"version": "0.4.0-alpha-20230515125426-a472464",
"version": "0.4.0-alpha-20230515131253-e1eec20",
"description": "Fetch API implementation for Node",
"sideEffects": false,
"dependencies": {
"@whatwg-node/events": "0.1.0-alpha-20230515125426-a472464",
"@whatwg-node/events": "0.1.0-alpha-20230515131253-e1eec20",
"busboy": "^1.6.0",

@@ -9,0 +9,0 @@ "fast-querystring": "^1.1.1",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc