Socket
Socket
Sign inDemoInstall

node-fetch

Package Overview
Dependencies
Maintainers
4
Versions
96
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-fetch - npm Package Compare versions

Comparing version 2.6.2 to 2.6.3

39

lib/index.es.js

@@ -6,2 +6,3 @@ process.emitWarning("The .es.js file is deprecated. Use .mjs instead.");

import Url from 'url';
import { URL } from 'whatwg-url';
import https from 'https';

@@ -1146,2 +1147,34 @@ import zlib from 'zlib';

/**
* Wrapper around `new URL` to handle arbitrary URLs
*
* @param {string} urlStr
* @return {void}
*/
function parseURL(urlStr) {
/*
Check whether the URL is absolute or not
Scheme: https://tools.ietf.org/html/rfc3986#section-3.1
Absolute URL: https://tools.ietf.org/html/rfc3986#section-4.3
*/
if (/^[a-zA-Z][a-zA-Z\d+\-.]*:/.exec(urlStr)) {
const url = new URL(urlStr);
return {
path: url.pathname,
pathname: url.pathname,
hostname: url.hostname,
protocol: url.protocol,
port: url.port,
hash: url.hash,
search: url.search,
query: url.query,
href: url.href
};
}
// Fallback to old implementation for arbitrary URLs
return parse_url(urlStr);
}
const streamDestructionSupported = 'destroy' in Stream.Readable.prototype;

@@ -1183,10 +1216,10 @@

// `href` property anyway)
parsedURL = parse_url(input.href);
parsedURL = parseURL(input.href);
} else {
// coerce input to a string before attempting to parse
parsedURL = parse_url(`${input}`);
parsedURL = parseURL(`${input}`);
}
input = {};
} else {
parsedURL = parse_url(input.url);
parsedURL = parseURL(input.url);
}

@@ -1193,0 +1226,0 @@

@@ -10,2 +10,3 @@ 'use strict';

var Url = _interopDefault(require('url'));
var whatwgUrl = require('whatwg-url');
var https = _interopDefault(require('https'));

@@ -1150,2 +1151,34 @@ var zlib = _interopDefault(require('zlib'));

/**
* Wrapper around `new URL` to handle arbitrary URLs
*
* @param {string} urlStr
* @return {void}
*/
function parseURL(urlStr) {
/*
Check whether the URL is absolute or not
Scheme: https://tools.ietf.org/html/rfc3986#section-3.1
Absolute URL: https://tools.ietf.org/html/rfc3986#section-4.3
*/
if (/^[a-zA-Z][a-zA-Z\d+\-.]*:/.exec(urlStr)) {
const url = new whatwgUrl.URL(urlStr);
return {
path: url.pathname,
pathname: url.pathname,
hostname: url.hostname,
protocol: url.protocol,
port: url.port,
hash: url.hash,
search: url.search,
query: url.query,
href: url.href
};
}
// Fallback to old implementation for arbitrary URLs
return parse_url(urlStr);
}
const streamDestructionSupported = 'destroy' in Stream.Readable.prototype;

@@ -1187,10 +1220,10 @@

// `href` property anyway)
parsedURL = parse_url(input.href);
parsedURL = parseURL(input.href);
} else {
// coerce input to a string before attempting to parse
parsedURL = parse_url(`${input}`);
parsedURL = parseURL(`${input}`);
}
input = {};
} else {
parsedURL = parse_url(input.url);
parsedURL = parseURL(input.url);
}

@@ -1197,0 +1230,0 @@

8

package.json
{
"name": "node-fetch",
"version": "2.6.2",
"version": "2.6.3",
"description": "A light-weight module that brings window.fetch to node.js",

@@ -39,2 +39,5 @@ "main": "lib/index.js",

"homepage": "https://github.com/bitinn/node-fetch",
"dependencies": {
"whatwg-url": "^5.0.0"
},
"devDependencies": {

@@ -64,5 +67,4 @@ "@ungap/url-search-params": "^0.1.2",

"string-to-arraybuffer": "^1.0.2",
"teeny-request": "3.7.0",
"whatwg-url": "^5.0.0"
"teeny-request": "3.7.0"
}
}

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