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

exp-fetch

Package Overview
Dependencies
Maintainers
16
Versions
44
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

exp-fetch - npm Package Compare versions

Comparing version

to
5.3.2

73

index.js

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

const isRedirect = require("./lib/isRedirect");
const ensureAbsoluteUrl = require("./lib/ensureAbsoluteUrl");
const currentAppConfig = require("./lib/currentAppConfig");

@@ -233,3 +232,3 @@

if (redirectCount++ < maximumNumberOfRedirects) {
const location = ensureAbsoluteUrl(response.headers, url);
const location = new URL(response.headers.location, url).toString();
return performRequest(location, headers, explicitTimeout, method, body, redirectCount, callback);

@@ -245,44 +244,48 @@ } else {

function fetch(method, options, optionalBody, resultCallback) {
let url = options;
if (typeof optionalBody === "function") {
resultCallback = optionalBody;
optionalBody = null;
}
const extraHeaders = {};
try {
let url = options;
if (getCorrelationId) {
const correlationId = getCorrelationId();
if (correlationId) {
extraHeaders[correlationIdHeader] = correlationId;
const extraHeaders = {};
if (getCorrelationId) {
const correlationId = getCorrelationId();
if (correlationId) {
extraHeaders[correlationIdHeader] = correlationId;
}
}
}
const headers = Object.assign({}, globalHeaders, options.headers, extraHeaders);
let explicitTimeout = null;
if (typeof options === "object") {
if (options.url) {
url = options.url;
const headers = Object.assign({}, globalHeaders, options.headers, extraHeaders);
let explicitTimeout = null;
if (typeof options === "object") {
if (options.url) {
url = options.url;
}
if (options.timeout) {
explicitTimeout = options.timeout;
}
}
if (options.timeout) {
explicitTimeout = options.timeout;
if (currentAppConfig.name) {
headers["x-exp-fetch-appname"] = currentAppConfig.name;
}
}
if (currentAppConfig.name) {
headers["x-exp-fetch-appname"] = currentAppConfig.name;
if (resultCallback) {
performRequest(url, headers, explicitTimeout, method, optionalBody, 0, resultCallback, onRequestInit);
} else {
return new Promise((resolve, reject) => {
performRequest(url, headers, explicitTimeout, method, optionalBody, 0, (err, content) => {
if (err) return reject(err);
return resolve(content);
}, onRequestInit);
});
}
} catch (err) {
return resultCallback ? resultCallback(err) : Promise.reject(err);
}
if (typeof optionalBody === "function") {
resultCallback = optionalBody;
optionalBody = null;
}
if (resultCallback) {
performRequest(url, headers, explicitTimeout, method, optionalBody, 0, resultCallback, onRequestInit);
} else {
return new Promise((resolve, reject) => {
performRequest(url, headers, explicitTimeout, method, optionalBody, 0, (err, content) => {
if (err) return reject(err);
return resolve(content);
}, onRequestInit);
});
}
function onRequestInit() {

@@ -289,0 +292,0 @@ if (behavior.onRequestInit) {

{
"name": "exp-fetch",
"version": "5.3.1",
"version": "5.3.2",
"description": "A small pluggable fetch lib",

@@ -26,10 +26,10 @@ "main": "index.js",

"chai": "^4.3.6",
"eslint": "^8.3.0",
"eslint-config-exp": "^0.2.0",
"mocha": "^9.2.0",
"nock": "^13.2.2"
"eslint": "^8.26.0",
"eslint-config-exp": "^0.5.0",
"mocha": "^10.1.0",
"nock": "^13.2.9"
},
"dependencies": {
"clone": "^2.1.1",
"exp-asynccache": "^2.0.0",
"exp-asynccache": "^3.2.0",
"got": "^11.8.3",

@@ -36,0 +36,0 @@ "lru-cache": "^6.0.0",