Socket
Socket
Sign inDemoInstall

got

Package Overview
Dependencies
Maintainers
2
Versions
176
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

got - npm Package Compare versions

Comparing version 11.1.0 to 11.1.1

92

dist/source/core/index.js

@@ -288,4 +288,2 @@ "use strict";

const rawOptions = options;
const searchParameters = options === null || options === void 0 ? void 0 : options.searchParams;
const hooks = options === null || options === void 0 ? void 0 : options.hooks;
if (is_1.default.object(url) && !is_1.default.urlInstance(url)) {

@@ -303,25 +301,2 @@ options = { ...defaults, ...url, ...options };

}
// Prevent duplicating default search params & hooks
if (searchParameters === undefined) {
delete options.searchParams;
}
else {
options.searchParams = searchParameters;
}
if (hooks === undefined) {
delete options.hooks;
}
else {
options.hooks = hooks;
}
// Setting options to `undefined` turns off its functionalities
if (rawOptions && defaults) {
for (const key in rawOptions) {
// @ts-ignore Dear TypeScript, all object keys are strings (or symbols which are NOT enumerable).
if (is_1.default.undefined(rawOptions[key]) && !is_1.default.undefined(defaults[key])) {
// @ts-ignore See the note above
options[key] = defaults[key];
}
}
}
// TODO: Deprecate URL options in Got 12.

@@ -358,6 +333,3 @@ // Support extend-specific options

// `options.headers`
if (is_1.default.undefined(options.headers)) {
options.headers = {};
}
else if (options.headers === (defaults === null || defaults === void 0 ? void 0 : defaults.headers)) {
if (options.headers === (defaults === null || defaults === void 0 ? void 0 : defaults.headers)) {
options.headers = { ...options.headers };

@@ -377,15 +349,14 @@ }

// `options.searchParams`
if (options.searchParams) {
if (!is_1.default.string(options.searchParams) && !(options.searchParams instanceof url_1.URLSearchParams)) {
validateSearchParameters(options.searchParams);
if ('searchParams' in options) {
if (options.searchParams && options.searchParams !== (defaults === null || defaults === void 0 ? void 0 : defaults.searchParams)) {
if (!is_1.default.string(options.searchParams) && !(options.searchParams instanceof url_1.URLSearchParams)) {
validateSearchParameters(options.searchParams);
}
options.searchParams = new url_1.URLSearchParams(options.searchParams);
// `normalizeArguments()` is also used to merge options
(_a = defaults === null || defaults === void 0 ? void 0 : defaults.searchParams) === null || _a === void 0 ? void 0 : _a.forEach((value, key) => {
options.searchParams.append(key, value);
});
}
options.searchParams = new url_1.URLSearchParams(options.searchParams);
// `normalizeArguments()` is also used to merge options
(_a = defaults === null || defaults === void 0 ? void 0 : defaults.searchParams) === null || _a === void 0 ? void 0 : _a.forEach((value, key) => {
options.searchParams.append(key, value);
});
}
else {
options.searchParams = defaults === null || defaults === void 0 ? void 0 : defaults.searchParams;
}
// `options.username` & `options.password`

@@ -499,2 +470,3 @@ options.username = (_b = options.username) !== null && _b !== void 0 ? _b : '';

// `options.hooks`
const areHooksDefault = options.hooks === (defaults === null || defaults === void 0 ? void 0 : defaults.hooks);
options.hooks = { ...options.hooks };

@@ -515,3 +487,3 @@ for (const event of exports.knownHookEvents) {

}
if (defaults) {
if (defaults && !areHooksDefault) {
for (const event of exports.knownHookEvents) {

@@ -651,2 +623,5 @@ const defaultHooks = defaults.hooks[event];

response.once('error', (error) => {
// Force clean-up, because some packages don't do this.
// TODO: Fix decompress-response
response.destroy();
this._beforeError(new ReadError(error, this));

@@ -785,6 +760,9 @@ });

this[kCancelTimeouts] = timed_out_1.default(request, timeout, url);
request.once('response', response => {
const responseEventName = options.cache ? 'cacheableResponse' : 'response';
request.once(responseEventName, (response) => {
this._onResponse(response);
});
request.once('error', (error) => {
// Force clean-up, because some packages (e.g. nock) don't do this.
request.destroy();
if (error instanceof timed_out_1.TimeoutError) {

@@ -834,12 +812,13 @@ error = new TimeoutError(error, this.timings, this);

// This is ugly
const cacheRequest = cacheableStore.get(options.cache)(options, resolve);
const cacheRequest = cacheableStore.get(options.cache)(options, response => {
const typedResponse = response;
const { req } = typedResponse;
if (req) {
req.emit('cacheableResponse', typedResponse);
}
resolve(typedResponse);
});
// Restore options
options.url = url;
cacheRequest.once('error', (error) => {
if (error instanceof CacheableRequest.CacheError) {
reject(new CacheError(error, this));
return;
}
reject(error);
});
cacheRequest.once('error', reject);
cacheRequest.once('request', resolve);

@@ -896,2 +875,3 @@ });

const isHttps = url.protocol === 'https:';
// Fallback function
let fallbackFn;

@@ -905,12 +885,14 @@ if (options.http2) {

const realFn = (_a = options.request) !== null && _a !== void 0 ? _a : fallbackFn;
const fn = options.cache ? this._createCacheableRequest.bind(this) : realFn;
// Cache support
const fn = options.cache ? this._createCacheableRequest : realFn;
// Pass an agent directly when HTTP2 is disabled
if (agent && !options.http2) {
options.agent = agent[isHttps ? 'https' : 'http'];
}
// Prepare plain HTTP request options
options[kRequest] = realFn;
delete options.request;
delete options.timeout;
let requestOrResponse;
try {
requestOrResponse = await fn(url, options);
let requestOrResponse = await fn(url, options);
if (is_1.default.undefined(requestOrResponse)) {

@@ -940,4 +922,4 @@ requestOrResponse = fallbackFn(url, options);

catch (error) {
if (error instanceof RequestError) {
throw error;
if (error instanceof CacheableRequest.CacheError) {
throw new CacheError(error, this);
}

@@ -944,0 +926,0 @@ throw new RequestError(error.message, error, this);

@@ -92,4 +92,2 @@ "use strict";

}
// A bug.
// eslint-disable-next-line @typescript-eslint/return-await
return iterateHandlers(normalizedOptions);

@@ -102,4 +100,2 @@ }

else {
// A bug.
// eslint-disable-next-line @typescript-eslint/return-await
return create_rejection_1.default(error, defaults.options.hooks.beforeError, (_b = options === null || options === void 0 ? void 0 : options.hooks) === null || _b === void 0 ? void 0 : _b.beforeError);

@@ -106,0 +102,0 @@ }

@@ -28,3 +28,3 @@ /// <reference types="node" />

resolveBodyOnly?: false;
responseType: 'json';
responseType?: 'json';
}>;

@@ -31,0 +31,0 @@ export declare type OptionsOfBufferResponseBody = Merge<Options, {

{
"name": "got",
"version": "11.1.0",
"version": "11.1.1",
"description": "Human-friendly and powerful HTTP request library for Node.js",

@@ -65,3 +65,3 @@ "license": "MIT",

"@types/lolex": "^5.1.0",
"@types/node": "13.1.2",
"@types/node": "^13.13.4",
"@types/node-fetch": "^2.5.5",

@@ -68,0 +68,0 @@ "@types/request": "^2.48.4",

Sorry, the diff of this file is too big to display

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