@@ -5464,6 +5464,29 @@ var Writable = (__nccwpck_require__(2781).Writable);
54645464var assert = __nccwpck_require__(9491);
54655465var debug = __nccwpck_require__(9605);
54665466
5467+ // Whether to use the native URL object or the legacy url module
5468+ var useNativeURL = false;
5469+ try {
5470+ assert(new URL());
5471+ }
5472+ catch (error) {
5473+ useNativeURL = error.code === "ERR_INVALID_URL";
5474+ }
5475+
5476+ // URL fields to preserve in copy operations
5477+ var preservedUrlFields = [
5478+ "auth",
5479+ "host",
5480+ "hostname",
5481+ "href",
5482+ "path",
5483+ "pathname",
5484+ "port",
5485+ "protocol",
5486+ "query",
5487+ "search",
5488+ ];
5489+
54675490// Create handlers that pass events from native requests
54685491var events = ["abort", "aborted", "connect", "error", "socket", "timeout"];
54695492var eventHandlers = Object.create(null);
@@ -5473,19 +5496,20 @@ events.forEach(function (event) {
54735496 };
54745497});
54755498
5499+ // Error types with codes
54765500var InvalidUrlError = createErrorType(
54775501 "ERR_INVALID_URL",
54785502 "Invalid URL",
54795503 TypeError
54805504);
5481- // Error types with codes
54825505var RedirectionError = createErrorType(
54835506 "ERR_FR_REDIRECTION_FAILURE",
54845507 "Redirected request failed"
54855508);
54865509var TooManyRedirectsError = createErrorType(
54875510 "ERR_FR_TOO_MANY_REDIRECTS",
5488- "Maximum number of redirects exceeded"
5511+ "Maximum number of redirects exceeded",
5512+ RedirectionError
54895513);
54905514var MaxBodyLengthExceededError = createErrorType(
54915515 "ERR_FR_MAX_BODY_LENGTH_EXCEEDED",
@@ -5520,7 +5544,13 @@ function RedirectableRequest(options, responseCallback) {
55205544 // React to responses of native requests
55215545 var self = this;
55225546 this._onNativeResponse = function (response) {
5523- self._processResponse(response);
5547+ try {
5548+ self._processResponse(response);
5549+ }
5550+ catch (cause) {
5551+ self.emit("error", cause instanceof RedirectionError ?
5552+ cause : new RedirectionError({ cause: cause }));
5553+ }
55245554 };
55255555
55265556 // Perform the first request
@@ -5738,8 +5768,7 @@ RedirectableRequest.prototype._performRequest = function () {
57385768 var protocol = this._options.protocol;
57395769 var nativeProtocol = this._options.nativeProtocols[protocol];
57405770 if (!nativeProtocol) {
5741- this.emit("error", new TypeError("Unsupported protocol " + protocol));
5742- return;
5771+ throw new TypeError("Unsupported protocol " + protocol);
57435772 }
57445773
57455774 // If specified, use the agent corresponding to the protocol
@@ -5838,8 +5867,7 @@ RedirectableRequest.prototype._processResponse = function (response) {
58385867 // RFC7231§6.4: A client SHOULD detect and intervene
58395868 // in cyclical redirections (i.e., "infinite" redirection loops).
58405869 if (++this._redirectCount > this._options.maxRedirects) {
5841- this.emit("error", new TooManyRedirectsError());
5842- return;
5870+ throw new TooManyRedirectsError();
58435871 }
58445872
58455873 // Store the request headers if applicable
@@ -5873,33 +5901,23 @@ RedirectableRequest.prototype._processResponse = function (response) {
58735901 var currentHostHeader = removeMatchingHeaders(/^host$/i, this._options.headers);
58745902
58755903 // If the redirect is relative, carry over the host of the last request
5876- var currentUrlParts = url.parse (this._currentUrl);
5904+ var currentUrlParts = parseUrl (this._currentUrl);
58775905 var currentHost = currentHostHeader || currentUrlParts.host;
58785906 var currentUrl = /^\w+:/.test(location) ? this._currentUrl :
58795907 url.format(Object.assign(currentUrlParts, { host: currentHost }));
58805908
5881- // Determine the URL of the redirection
5882- var redirectUrl;
5883- try {
5884- redirectUrl = url.resolve(currentUrl, location);
5885- }
5886- catch (cause) {
5887- this.emit("error", new RedirectionError({ cause: cause }));
5888- return;
5889- }
5890-
58915909 // Create the redirected request
5892- debug("redirecting to", redirectUrl);
5910+ var redirectUrl = resolveUrl(location, currentUrl);
5911+ debug("redirecting to", redirectUrl.href);
58935912 this._isRedirect = true;
5894- var redirectUrlParts = url.parse(redirectUrl);
5895- Object.assign(this._options, redirectUrlParts);
5913+ spreadUrlObject(redirectUrl, this._options);
58965914
58975915 // Drop confidential headers when redirecting to a less secure protocol
58985916 // or to a different domain that is not a superdomain
5899- if (redirectUrlParts .protocol !== currentUrlParts.protocol &&
5900- redirectUrlParts .protocol !== "https:" ||
5901- redirectUrlParts .host !== currentHost &&
5902- !isSubdomain(redirectUrlParts .host, currentHost)) {
5917+ if (redirectUrl .protocol !== currentUrlParts.protocol &&
5918+ redirectUrl .protocol !== "https:" ||
5919+ redirectUrl .host !== currentHost &&
5920+ !isSubdomain(redirectUrl .host, currentHost)) {
59035921 removeMatchingHeaders(/^(?:authorization|cookie)$/i, this._options.headers);
59045922 }
59055923
@@ -5914,23 +5932,12 @@ RedirectableRequest.prototype._processResponse = function (response) {
59145932 method: method,
59155933 headers: requestHeaders,
59165934 };
5917- try {
5918- beforeRedirect(this._options, responseDetails, requestDetails);
5919- }
5920- catch (err) {
5921- this.emit("error", err);
5922- return;
5923- }
5935+ beforeRedirect(this._options, responseDetails, requestDetails);
59245936 this._sanitizeOptions(this._options);
59255937 }
59265938
59275939 // Perform the redirected request
5928- try {
5929- this._performRequest();
5930- }
5931- catch (cause) {
5932- this.emit("error", new RedirectionError({ cause: cause }));
5933- }
5940+ this._performRequest();
59345941};
59355942
59365943// Wraps the key/value object of protocols with redirect functionality
@@ -5950,27 +5957,16 @@ function wrap(protocols) {
59505957
59515958 // Executes a request, following redirects
59525959 function request(input, options, callback) {
5953- // Parse parameters
5954- if (isString(input)) {
5955- var parsed;
5956- try {
5957- parsed = urlToOptions(new URL(input));
5958- }
5959- catch (err) {
5960- /* istanbul ignore next */
5961- parsed = url.parse(input);
5962- }
5963- if (!isString(parsed.protocol)) {
5964- throw new InvalidUrlError({ input });
5965- }
5966- input = parsed;
5960+ // Parse parameters, ensuring that input is an object
5961+ if (isURL(input)) {
5962+ input = spreadUrlObject(input);
59675963 }
5968- else if (URL && (input instanceof URL )) {
5969- input = urlToOptions( input);
5964+ else if (isString (input)) {
5965+ input = spreadUrlObject(parseUrl( input) );
59705966 }
59715967 else {
59725968 callback = options;
5973- options = input;
5969+ options = validateUrl( input) ;
59745970 input = { protocol: protocol };
59755971 }
59765972 if (isFunction(options)) {
@@ -6009,27 +6005,57 @@ function wrap(protocols) {
60096005 return exports;
60106006}
60116007
6012- /* istanbul ignore next */
60136008function noop() { /* empty */ }
60146009
6015- // from https://github.com/nodejs/node/blob/master/lib/internal/url.js
6016- function urlToOptions(urlObject) {
6017- var options = {
6018- protocol: urlObject.protocol,
6019- hostname: urlObject.hostname.startsWith("[") ?
6020- /* istanbul ignore next */
6021- urlObject.hostname.slice(1, -1) :
6022- urlObject.hostname,
6023- hash: urlObject.hash,
6024- search: urlObject.search,
6025- pathname: urlObject.pathname,
6026- path: urlObject.pathname + urlObject.search,
6027- href: urlObject.href,
6028- };
6029- if (urlObject.port !== "") {
6030- options.port = Number(urlObject.port);
6010+ function parseUrl(input) {
6011+ var parsed;
6012+ /* istanbul ignore else */
6013+ if (useNativeURL) {
6014+ parsed = new URL(input);
6015+ }
6016+ else {
6017+ // Ensure the URL is valid and absolute
6018+ parsed = validateUrl(url.parse(input));
6019+ if (!isString(parsed.protocol)) {
6020+ throw new InvalidUrlError({ input });
6021+ }
6022+ }
6023+ return parsed;
6024+ }
6025+
6026+ function resolveUrl(relative, base) {
6027+ /* istanbul ignore next */
6028+ return useNativeURL ? new URL(relative, base) : parseUrl(url.resolve(base, relative));
6029+ }
6030+
6031+ function validateUrl(input) {
6032+ if (/^\[/.test(input.hostname) && !/^\[[:0-9a-f]+\]$/i.test(input.hostname)) {
6033+ throw new InvalidUrlError({ input: input.href || input });
6034+ }
6035+ if (/^\[/.test(input.host) && !/^\[[:0-9a-f]+\](:\d+)?$/i.test(input.host)) {
6036+ throw new InvalidUrlError({ input: input.href || input });
6037+ }
6038+ return input;
6039+ }
6040+
6041+ function spreadUrlObject(urlObject, target) {
6042+ var spread = target || {};
6043+ for (var key of preservedUrlFields) {
6044+ spread[key] = urlObject[key];
6045+ }
6046+
6047+ // Fix IPv6 hostname
6048+ if (spread.hostname.startsWith("[")) {
6049+ spread.hostname = spread.hostname.slice(1, -1);
6050+ }
6051+ // Ensure port is a number
6052+ if (spread.port !== "") {
6053+ spread.port = Number(spread.port);
60316054 }
6032- return options;
6055+ // Concatenate path
6056+ spread.path = spread.search ? spread.pathname + spread.search : spread.pathname;
6057+
6058+ return spread;
60336059}
60346060
60356061function removeMatchingHeaders(regex, headers) {
@@ -6055,8 +6081,16 @@ function createErrorType(code, message, baseClass) {
60556081
60566082 // Attach constructor and set default properties
60576083 CustomError.prototype = new (baseClass || Error)();
6058- CustomError.prototype.constructor = CustomError;
6059- CustomError.prototype.name = "Error [" + code + "]";
6084+ Object.defineProperties(CustomError.prototype, {
6085+ constructor: {
6086+ value: CustomError,
6087+ enumerable: false,
6088+ },
6089+ name: {
6090+ value: "Error [" + code + "]",
6091+ enumerable: false,
6092+ },
6093+ });
60606094 return CustomError;
60616095}
60626096
@@ -6086,6 +6120,10 @@ function isBuffer(value) {
60866120 return typeof value === "object" && ("length" in value);
60876121}
60886122
6123+ function isURL(value) {
6124+ return URL && value instanceof URL;
6125+ }
6126+
60896127// Exports
60906128module.exports = wrap({ http: http, https: https });
60916129module.exports.wrap = wrap;
@@ -32134,7 +32172,7 @@ module.exports = parseParams
3213432172/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
3213532173
3213632174"use strict";
32137- // Axios v1.6.3 Copyright (c) 2023 Matt Zabriskie and contributors
32175+ // Axios v1.6.4 Copyright (c) 2024 Matt Zabriskie and contributors
3213832176
3213932177
3214032178const FormData$1 = __nccwpck_require__(2220);
@@ -33504,6 +33542,9 @@ function arrayToObject(arr) {
3350433542function formDataToJSON(formData) {
3350533543 function buildPath(path, value, target, index) {
3350633544 let name = path[index++];
33545+
33546+ if (name === '__proto__') return true;
33547+
3350733548 const isNumericKey = Number.isFinite(+name);
3350833549 const isLast = index >= path.length;
3350933550 name = !name && utils$1.isArray(target) ? target.length : name;
@@ -34155,7 +34196,7 @@ function buildFullPath(baseURL, requestedURL) {
3415534196 return requestedURL;
3415634197}
3415734198
34158- const VERSION = "1.6.3 ";
34199+ const VERSION = "1.6.4 ";
3415934200
3416034201function parseProtocol(url) {
3416134202 const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
0 commit comments