mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
lib: remove usage of url.parse
Since url.parse() is deprecated, it must not be used inside Node.js. PR-URL: https://github.com/nodejs/node/pull/36853 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Beth Griggs <bgriggs@redhat.com> Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
This commit is contained in:
18
lib/https.js
18
lib/https.js
@@ -37,7 +37,6 @@ const {
|
||||
require('internal/util').assertCrypto();
|
||||
|
||||
const tls = require('tls');
|
||||
const url = require('url');
|
||||
const { Agent: HttpAgent } = require('_http_agent');
|
||||
const {
|
||||
Server: HttpServer,
|
||||
@@ -296,27 +295,12 @@ Agent.prototype._evictSession = function _evictSession(key) {
|
||||
|
||||
const globalAgent = new Agent();
|
||||
|
||||
let urlWarningEmitted = false;
|
||||
function request(...args) {
|
||||
let options = {};
|
||||
|
||||
if (typeof args[0] === 'string') {
|
||||
const urlStr = ArrayPrototypeShift(args);
|
||||
try {
|
||||
options = urlToHttpOptions(new URL(urlStr));
|
||||
} catch (err) {
|
||||
options = url.parse(urlStr);
|
||||
if (!options.hostname) {
|
||||
throw err;
|
||||
}
|
||||
if (!urlWarningEmitted && !process.noDeprecation) {
|
||||
urlWarningEmitted = true;
|
||||
process.emitWarning(
|
||||
`The provided URL ${urlStr} is not a valid URL, and is supported ` +
|
||||
'in the https module solely for compatibility.',
|
||||
'DeprecationWarning', 'DEP0109');
|
||||
}
|
||||
}
|
||||
options = urlToHttpOptions(new URL(urlStr));
|
||||
} else if (args[0] && args[0][searchParamsSymbol] &&
|
||||
args[0][searchParamsSymbol][searchParamsSymbol]) {
|
||||
// url.URL instance
|
||||
|
||||
Reference in New Issue
Block a user