Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Socket
Sign inDemoInstall

get-it

Package Overview
Dependencies
Maintainers
47
Versions
159
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

get-it - npm Package Compare versions

Comparing version 8.4.12 to 8.4.13

29

dist/_chunks/defaultOptionsValidator.js

@@ -5,6 +5,5 @@ const isReactNative = typeof navigator > "u" ? !1 : navigator.product === "ReactNative", defaultOptions = { timeout: isReactNative ? 6e4 : 12e4 }, processOptions = function(opts) {

...typeof opts == "string" ? { url: opts } : opts
};
}, { searchParams } = new URL(options.url, "http://localhost");
if (options.timeout = normalizeTimeout(options.timeout), options.query) {
const { url, searchParams } = splitUrl(options.url);
for (const [key, value] of Object.entries(options.query)) {
for (const [key, value] of Object.entries(options.query))
if (value !== void 0)

@@ -16,26 +15,6 @@ if (Array.isArray(value))

searchParams.append(key, value);
const search = searchParams.toString();
search && (options.url = `${url}?${search}`);
}
}
return options.method = options.body && !options.method ? "POST" : (options.method || "GET").toUpperCase(), options;
const [url] = options.url.split("?"), search = searchParams.toString();
return search && (options.url = `${url}?${search}`), options.method = options.body && !options.method ? "POST" : (options.method || "GET").toUpperCase(), options;
};
function splitUrl(url) {
const qIndex = url.indexOf("?");
if (qIndex === -1)
return { url, searchParams: new URLSearchParams() };
const base = url.slice(0, qIndex), qs = url.slice(qIndex + 1), searchParams = new URLSearchParams(qs);
if (typeof searchParams.size == "number")
return { url: base, searchParams };
if (typeof decodeURIComponent != "function")
throw new Error(
"Broken `URLSearchParams` implementation, and `decodeURIComponent` is not defined"
);
const params = new URLSearchParams();
for (const pair of qs.split("&")) {
const [key, value] = pair.split("=");
key && params.append(decodeURIComponent(key), decodeURIComponent(value || ""));
}
return { url: base, searchParams: params };
}
function normalizeTimeout(time) {

@@ -42,0 +21,0 @@ if (time === !1 || time === 0)

2

package.json
{
"name": "get-it",
"version": "8.4.12",
"version": "8.4.13",
"description": "Generic HTTP request library for node, browsers and workers",

@@ -5,0 +5,0 @@ "keywords": [

@@ -14,2 +14,5 @@ import type {MiddlewareHooks, RequestOptions} from '../types'

// Allow parsing relative URLs by setting the origin to `http://localhost`
const {searchParams} = new URL(options.url, 'http://localhost')
// Normalize timeouts

@@ -20,4 +23,2 @@ options.timeout = normalizeTimeout(options.timeout)

if (options.query) {
const {url, searchParams} = splitUrl(options.url)
for (const [key, value] of Object.entries(options.query)) {

@@ -33,10 +34,10 @@ if (value !== undefined) {

}
// Merge back params into url
const search = searchParams.toString()
if (search) {
options.url = `${url}?${search}`
}
}
}
// Merge back params into url
const [url] = options.url.split('?')
const search = searchParams.toString()
if (search) {
options.url = `${url}?${search}`
}

@@ -50,46 +51,2 @@ // Implicit POST if we have not specified a method but have a body

/**
* Given a string URL, extracts the query string and URL from each other, and returns them.
* Note that we cannot use the `URL` constructor because of old React Native versions which are
* majorly broken and returns incorrect results:
*
* (`new URL('http://foo/?a=b').toString()` == 'http://foo/?a=b/')
*/
function splitUrl(url: string): {url: string; searchParams: URLSearchParams} {
const qIndex = url.indexOf('?')
if (qIndex === -1) {
return {url, searchParams: new URLSearchParams()}
}
const base = url.slice(0, qIndex)
const qs = url.slice(qIndex + 1)
const searchParams = new URLSearchParams(qs)
// Buggy React Native versions do not implement `size`, so if we have one,
// we should be able to use a functioning `URLSearchParams` implementation
if (typeof searchParams.size === 'number') {
return {url: base, searchParams}
}
// Sanity-check; we do not know of any environment where this is the case,
// but if it is, we should not proceed without giving a descriptive error
if (typeof decodeURIComponent !== 'function') {
throw new Error(
'Broken `URLSearchParams` implementation, and `decodeURIComponent` is not defined',
)
}
// Another brokenness in React Native: `URLSearchParams` does not accept a string argument,
// so we'll have do attempt to destructure the query string ourselves :(
const params = new URLSearchParams()
for (const pair of qs.split('&')) {
const [key, value] = pair.split('=')
if (key) {
params.append(decodeURIComponent(key), decodeURIComponent(value || ''))
}
}
return {url: base, searchParams: params}
}
function normalizeTimeout(time: RequestOptions['timeout']) {

@@ -96,0 +53,0 @@ if (time === false || time === 0) {

Sorry, the diff of this file is not supported yet

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc