Socket
Socket
Sign inDemoInstall

@octokit/request

Package Overview
Dependencies
16
Maintainers
4
Versions
102
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 6.2.2 to 6.2.3

43

dist-node/index.js

@@ -13,3 +13,3 @@ 'use strict';

const VERSION = "6.2.2";
const VERSION = "6.2.3";

@@ -22,13 +22,9 @@ function getBufferResponse(response) {

const log = requestOptions.request && requestOptions.request.log ? requestOptions.request.log : console;
if (isPlainObject.isPlainObject(requestOptions.body) || Array.isArray(requestOptions.body)) {
requestOptions.body = JSON.stringify(requestOptions.body);
}
let headers = {};
let status;
let url;
const fetch = requestOptions.request && requestOptions.request.fetch || globalThis.fetch ||
/* istanbul ignore next */
nodeFetch;
const fetch = requestOptions.request && requestOptions.request.fetch || globalThis.fetch || /* istanbul ignore next */nodeFetch;
return fetch(requestOptions.url, Object.assign({

@@ -39,3 +35,4 @@ method: requestOptions.method,

redirect: requestOptions.redirect
}, // `requestOptions.request.agent` type is incompatible
},
// `requestOptions.request.agent` type is incompatible
// see https://github.com/octokit/types.ts/pull/264

@@ -45,7 +42,5 @@ requestOptions.request)).then(async response => {

status = response.status;
for (const keyAndValue of response.headers) {
headers[keyAndValue[0]] = keyAndValue[1];
}
if ("deprecation" in headers) {

@@ -56,8 +51,6 @@ const matches = headers.link && headers.link.match(/<([^>]+)>; rel="deprecation"/);

}
if (status === 204 || status === 205) {
return;
} // GitHub API returns 200 for HEAD requests
}
// GitHub API returns 200 for HEAD requests
if (requestOptions.method === "HEAD") {

@@ -67,3 +60,2 @@ if (status < 400) {

}
throw new requestError.RequestError(response.statusText, status, {

@@ -79,3 +71,2 @@ response: {

}
if (status === 304) {

@@ -92,3 +83,2 @@ throw new requestError.RequestError("Not modified", status, {

}
if (status >= 400) {

@@ -107,3 +97,2 @@ const data = await getResponseData(response);

}
return getResponseData(response);

@@ -124,20 +113,15 @@ }).then(data => {

}
async function getResponseData(response) {
const contentType = response.headers.get("content-type");
if (/application\/json/.test(contentType)) {
return response.json();
}
if (!contentType || /^text\/|charset=utf-8$/.test(contentType)) {
return response.text();
}
return getBufferResponse(response);
}
function toErrorMessage(data) {
if (typeof data === "string") return data; // istanbul ignore else - just in case
if (typeof data === "string") return data;
// istanbul ignore else - just in case
if ("message" in data) {

@@ -147,7 +131,5 @@ if (Array.isArray(data.errors)) {

}
return data.message;
} // istanbul ignore next - just in case
}
// istanbul ignore next - just in case
return `Unknown error: ${JSON.stringify(data)}`;

@@ -158,14 +140,10 @@ }

const endpoint = oldEndpoint.defaults(newDefaults);
const newApi = function (route, parameters) {
const endpointOptions = endpoint.merge(route, parameters);
if (!endpointOptions.request || !endpointOptions.request.hook) {
return fetchWrapper(endpoint.parse(endpointOptions));
}
const request = (route, parameters) => {
return fetchWrapper(endpoint.parse(endpoint.merge(route, parameters)));
};
Object.assign(request, {

@@ -177,3 +155,2 @@ endpoint,

};
return Object.assign(newApi, {

@@ -180,0 +157,0 @@ endpoint,

@@ -1,1 +0,1 @@

export const VERSION = "6.2.2";
export const VERSION = "6.2.3";

@@ -1,1 +0,1 @@

export declare const VERSION = "6.2.2";
export declare const VERSION = "6.2.3";

@@ -7,3 +7,3 @@ import { endpoint } from '@octokit/endpoint';

const VERSION = "6.2.2";
const VERSION = "6.2.3";

@@ -10,0 +10,0 @@ function getBufferResponse(response) {

{
"name": "@octokit/request",
"description": "Send parameterized requests to GitHub's APIs with sensible defaults in browsers and Node",
"version": "6.2.2",
"version": "6.2.3",
"license": "MIT",

@@ -26,3 +26,3 @@ "files": [

"@octokit/request-error": "^3.0.0",
"@octokit/types": "^8.0.0",
"@octokit/types": "^9.0.0",
"is-plain-object": "^5.0.0",

@@ -41,3 +41,3 @@ "node-fetch": "^2.6.7",

"@types/lolex": "^5.1.0",
"@types/node": "^16.0.0",
"@types/node": "^18.0.0",
"@types/node-fetch": "^2.3.3",

@@ -48,3 +48,3 @@ "@types/once": "^1.4.0",

"lolex": "^6.0.0",
"prettier": "2.7.1",
"prettier": "2.8.3",
"semantic-release-plugin-update-version-in-files": "^1.0.0",

@@ -51,0 +51,0 @@ "string-to-arraybuffer": "^1.0.2",

@@ -6,3 +6,3 @@ # request.js

[![@latest](https://img.shields.io/npm/v/@octokit/request.svg)](https://www.npmjs.com/package/@octokit/request)
[![Build Status](https://github.com/octokit/request.js/workflows/Test/badge.svg)](https://github.com/octokit/request.js/actions?query=workflow%3ATest+branch%3Amaster)
[![Build Status](https://github.com/octokit/request.js/workflows/Test/badge.svg)](https://github.com/octokit/request.js/actions?query=workflow%3ATest+branch%3Amain)

@@ -75,6 +75,6 @@ `@octokit/request` is a request library for browsers & node that makes it easier

Load <code>@octokit/request</code> directly from <a href="https://cdn.skypack.dev">cdn.skypack.dev</a>
```html
<script type="module">
import { request } from "https://cdn.skypack.dev/@octokit/request";
import { request } from "https://cdn.skypack.dev/@octokit/request";
</script>

@@ -81,0 +81,0 @@ ```

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc