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

robust-http-fetch

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

robust-http-fetch - npm Package Compare versions

Comparing version 1.1.8 to 1.1.9

24

index.js

@@ -27,3 +27,3 @@ /**

const {timeout, maxRequests} = init;
const oneoffFetchFn = oneoffFetch(url, init);
const fetcher = oneoffFetch(url, init);

@@ -33,5 +33,5 @@ // container holding scheduled timer, entry is a 2-values array, 1st is SN(SeqNumber) of scheduled request, 2nd is timer ID;

const oneoffFetchFnWrapper = () => {
const oneoffFetchWrapper = () => {
try {
const promise = oneoffFetchFn();
const promise = fetcher();
return Promise.resolve(promise);

@@ -45,3 +45,3 @@ } catch (e) {

logger(`#${sn} request about to fire`);
const promise = oneoffFetchFnWrapper();
const promise = oneoffFetchWrapper();
cb(promise, sn, startTime);

@@ -117,5 +117,5 @@ };

const isBrowser = new Function("try {return window && this===window;}catch(e){ return false;}");
const fetcher = (isBrowser() && window.fetch) || require('node-fetch');
const request = (isBrowser() && window.fetch) || require('node-fetch');
return () => fetcher(url, init);
return () => request(url, init);
}

@@ -136,9 +136,13 @@

try {
new URL(args[0]);
} catch (e) {
const urlPattern = new RegExp('^(https?:\\/\\/)?' + // protocol
'((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|localhost|' + // domain name
'((\\d{1,3}\\.){3}\\d{1,3}))' + // OR ip (v4) address
'(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*' + // port and path
'(\\?[;&a-z\\d%_.~+=-]*)?' + // query string
'(\\#[-a-z\\d_]*)?$', 'i'); // fragment locator
if (!!!urlPattern.test(args[0])) {
argsCheckedInfo.push(`url need to be provided as correct URL string value as web target for this request`);
}
if (typeof args[1] !== 'object') {
if (!args[1] || typeof args[1] !== 'object') {
argsCheckedInfo.push(`init parameter need to be provided as an object, at least give timeout and maxRequests properties`);

@@ -145,0 +149,0 @@ } else {

{
"name": "robust-http-fetch",
"description": "Redo the http request when timeout or failed, aim at providing resilience over plain one-off fetch request by doing retry delayed/failed requests",
"version": "1.1.8",
"version": "1.1.9",
"repository": {

@@ -6,0 +6,0 @@ "type": "git",

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