node-fetch
Advanced tools
Comparing version 2.6.2 to 2.6.3
@@ -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 @@ |
{ | ||
"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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
149812
24
4360
1
1
+ Addedwhatwg-url@^5.0.0
+ Addedtr46@0.0.3(transitive)
+ Addedwebidl-conversions@3.0.1(transitive)
+ Addedwhatwg-url@5.0.0(transitive)