diff --git a/dist/query.js b/dist/query.js index ddb9de1d..edc32156 100644 --- a/dist/query.js +++ b/dist/query.js @@ -67428,91 +67428,65 @@ var require_data = __commonJS({ } }); -// node_modules/fast-uri/lib/scopedChars.js -var require_scopedChars = __commonJS({ - "node_modules/fast-uri/lib/scopedChars.js"(exports2, module2) { - "use strict"; - var HEX = { - 0: 0, - 1: 1, - 2: 2, - 3: 3, - 4: 4, - 5: 5, - 6: 6, - 7: 7, - 8: 8, - 9: 9, - a: 10, - A: 10, - b: 11, - B: 11, - c: 12, - C: 12, - d: 13, - D: 13, - e: 14, - E: 14, - f: 15, - F: 15 - }; - module2.exports = { - HEX - }; - } -}); - // node_modules/fast-uri/lib/utils.js var require_utils4 = __commonJS({ "node_modules/fast-uri/lib/utils.js"(exports2, module2) { "use strict"; - var { HEX } = require_scopedChars(); - function normalizeIPv4(host) { - if (findToken(host, ".") < 3) { - return { host, isIPV4: false }; - } - const matches = host.match(/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/u) || []; - const [address] = matches; - if (address) { - return { host: stripLeadingZeros(address, "."), isIPV4: true }; - } else { - return { host, isIPV4: false }; - } - } - function stringArrayToHexStripped(input, keepZero = false) { + var isUUID = RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu); + var isIPv4 = RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u); + var isHexPair = RegExp.prototype.test.bind(/^[\da-f]{2}$/iu); + var isUnreserved = RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu); + var isPathCharacter = RegExp.prototype.test.bind(/^[\da-z\-._~!$&'()*+,;=:@/]$/iu); + function stringArrayToHexStripped(input) { let acc = ""; - let strip = true; - for (const c of input) { - if (HEX[c] === void 0) return void 0; - if (c !== "0" && strip === true) strip = false; - if (!strip) acc += c; + let code = 0; + let i = 0; + for (i = 0; i < input.length; i++) { + code = input[i].charCodeAt(0); + if (code === 48) { + continue; + } + if (!(code >= 48 && code <= 57 || code >= 65 && code <= 70 || code >= 97 && code <= 102)) { + return ""; + } + acc += input[i]; + break; + } + for (i += 1; i < input.length; i++) { + code = input[i].charCodeAt(0); + if (!(code >= 48 && code <= 57 || code >= 65 && code <= 70 || code >= 97 && code <= 102)) { + return ""; + } + acc += input[i]; } - if (keepZero && acc.length === 0) acc = "0"; return acc; } + var nonSimpleDomain = RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u); + function consumeIsZone(buffer) { + buffer.length = 0; + return true; + } + function consumeHextets(buffer, address, output) { + if (buffer.length) { + const hex = stringArrayToHexStripped(buffer); + if (hex !== "") { + address.push(hex); + } else { + output.error = true; + return false; + } + buffer.length = 0; + } + return true; + } function getIPV6(input) { let tokenCount = 0; const output = { error: false, address: "", zone: "" }; const address = []; const buffer = []; - let isZone = false; let endipv6Encountered = false; let endIpv6 = false; - function consume() { - if (buffer.length) { - if (isZone === false) { - const hex = stringArrayToHexStripped(buffer); - if (hex !== void 0) { - address.push(hex); - } else { - output.error = true; - return false; - } - } - buffer.length = 0; - } - return true; - } + let consume = consumeHextets; for (let i = 0; i < input.length; i++) { const cursor = input[i]; if (cursor === "[" || cursor === "]") { @@ -67522,31 +67496,30 @@ var require_utils4 = __commonJS({ if (endipv6Encountered === true) { endIpv6 = true; } - if (!consume()) { + if (!consume(buffer, address, output)) { break; } - tokenCount++; - address.push(":"); - if (tokenCount > 7) { + if (++tokenCount > 7) { output.error = true; break; } - if (i - 1 >= 0 && input[i - 1] === ":") { + if (i > 0 && input[i - 1] === ":") { endipv6Encountered = true; } + address.push(":"); continue; } else if (cursor === "%") { - if (!consume()) { + if (!consume(buffer, address, output)) { break; } - isZone = true; + consume = consumeIsZone; } else { buffer.push(cursor); continue; } } if (buffer.length) { - if (isZone) { + if (consume === consumeIsZone) { output.zone = buffer.join(""); } else if (endIpv6) { address.push(buffer.join("")); @@ -67557,7 +67530,7 @@ var require_utils4 = __commonJS({ output.address = address.join(""); return output; } - function normalizeIPv6(host, opts = {}) { + function normalizeIPv6(host) { if (findToken(host, ":") < 2) { return { host, isIPV6: false }; } @@ -67569,33 +67542,11 @@ var require_utils4 = __commonJS({ newHost += "%" + ipv6.zone; escapedHost += "%25" + ipv6.zone; } - return { host: newHost, escapedHost, isIPV6: true }; + return { host: newHost, isIPV6: true, escapedHost }; } else { return { host, isIPV6: false }; } } - function stripLeadingZeros(str, token) { - let out = ""; - let skip = true; - const l = str.length; - for (let i = 0; i < l; i++) { - const c = str[i]; - if (c === "0" && skip) { - if (i + 1 <= l && str[i + 1] === token || i + 1 === l) { - out += c; - skip = false; - } - } else { - if (c === token) { - skip = true; - } else { - skip = false; - } - out += c; - } - } - return out; - } function findToken(str, token) { let ind = 0; for (let i = 0; i < str.length; i++) { @@ -67603,89 +67554,187 @@ var require_utils4 = __commonJS({ } return ind; } - var RDS1 = /^\.\.?\//u; - var RDS2 = /^\/\.(?:\/|$)/u; - var RDS3 = /^\/\.\.(?:\/|$)/u; - var RDS5 = /^\/?(?:.|\n)*?(?=\/|$)/u; - function removeDotSegments(input) { + function removeDotSegments(path8) { + let input = path8; const output = []; - while (input.length) { - if (input.match(RDS1)) { - input = input.replace(RDS1, ""); - } else if (input.match(RDS2)) { - input = input.replace(RDS2, "/"); - } else if (input.match(RDS3)) { - input = input.replace(RDS3, "/"); - output.pop(); - } else if (input === "." || input === "..") { - input = ""; - } else { - const im = input.match(RDS5); - if (im) { - const s = im[0]; - input = input.slice(s.length); - output.push(s); + let nextSlash = -1; + let len = 0; + while (len = input.length) { + if (len === 1) { + if (input === ".") { + break; + } else if (input === "/") { + output.push("/"); + break; } else { - throw new Error("Unexpected dot segment condition"); + output.push(input); + break; + } + } else if (len === 2) { + if (input[0] === ".") { + if (input[1] === ".") { + break; + } else if (input[1] === "/") { + input = input.slice(2); + continue; + } + } else if (input[0] === "/") { + if (input[1] === "." || input[1] === "/") { + output.push("/"); + break; + } + } + } else if (len === 3) { + if (input === "/..") { + if (output.length !== 0) { + output.pop(); + } + output.push("/"); + break; + } + } + if (input[0] === ".") { + if (input[1] === ".") { + if (input[2] === "/") { + input = input.slice(3); + continue; + } + } else if (input[1] === "/") { + input = input.slice(2); + continue; + } + } else if (input[0] === "/") { + if (input[1] === ".") { + if (input[2] === "/") { + input = input.slice(2); + continue; + } else if (input[2] === ".") { + if (input[3] === "/") { + input = input.slice(3); + if (output.length !== 0) { + output.pop(); + } + continue; + } + } } } + if ((nextSlash = input.indexOf("/", 1)) === -1) { + output.push(input); + break; + } else { + output.push(input.slice(0, nextSlash)); + input = input.slice(nextSlash); + } } return output.join(""); } - function normalizeComponentEncoding(components, esc) { - const func = esc !== true ? escape : unescape; - if (components.scheme !== void 0) { - components.scheme = func(components.scheme); - } - if (components.userinfo !== void 0) { - components.userinfo = func(components.userinfo); - } - if (components.host !== void 0) { - components.host = func(components.host); + var HOST_DELIMS = { "@": "%40", "/": "%2F", "?": "%3F", "#": "%23", ":": "%3A" }; + var HOST_DELIM_RE = /[@/?#:]/g; + var HOST_DELIM_NO_COLON_RE = /[@/?#]/g; + function reescapeHostDelimiters(host, isIP) { + const re = isIP ? HOST_DELIM_NO_COLON_RE : HOST_DELIM_RE; + re.lastIndex = 0; + return host.replace(re, (ch) => HOST_DELIMS[ch]); + } + function normalizePercentEncoding(input, decodeUnreserved = false) { + if (input.indexOf("%") === -1) { + return input; } - if (components.path !== void 0) { - components.path = func(components.path); + let output = ""; + for (let i = 0; i < input.length; i++) { + if (input[i] === "%" && i + 2 < input.length) { + const hex = input.slice(i + 1, i + 3); + if (isHexPair(hex)) { + const normalizedHex = hex.toUpperCase(); + const decoded = String.fromCharCode(parseInt(normalizedHex, 16)); + if (decodeUnreserved && isUnreserved(decoded)) { + output += decoded; + } else { + output += "%" + normalizedHex; + } + i += 2; + continue; + } + } + output += input[i]; } - if (components.query !== void 0) { - components.query = func(components.query); + return output; + } + function normalizePathEncoding(input) { + let output = ""; + for (let i = 0; i < input.length; i++) { + if (input[i] === "%" && i + 2 < input.length) { + const hex = input.slice(i + 1, i + 3); + if (isHexPair(hex)) { + const normalizedHex = hex.toUpperCase(); + const decoded = String.fromCharCode(parseInt(normalizedHex, 16)); + if (decoded !== "." && isUnreserved(decoded)) { + output += decoded; + } else { + output += "%" + normalizedHex; + } + i += 2; + continue; + } + } + if (isPathCharacter(input[i])) { + output += input[i]; + } else { + output += escape(input[i]); + } } - if (components.fragment !== void 0) { - components.fragment = func(components.fragment); + return output; + } + function escapePreservingEscapes(input) { + let output = ""; + for (let i = 0; i < input.length; i++) { + if (input[i] === "%" && i + 2 < input.length) { + const hex = input.slice(i + 1, i + 3); + if (isHexPair(hex)) { + output += "%" + hex.toUpperCase(); + i += 2; + continue; + } + } + output += escape(input[i]); } - return components; + return output; } - function recomposeAuthority(components, options) { + function recomposeAuthority(component) { const uriTokens = []; - if (components.userinfo !== void 0) { - uriTokens.push(components.userinfo); + if (component.userinfo !== void 0) { + uriTokens.push(component.userinfo); uriTokens.push("@"); } - if (components.host !== void 0) { - let host = unescape(components.host); - const ipV4res = normalizeIPv4(host); - if (ipV4res.isIPV4) { - host = ipV4res.host; - } else { - const ipV6res = normalizeIPv6(ipV4res.host, { isIPV4: false }); + if (component.host !== void 0) { + let host = unescape(component.host); + if (!isIPv4(host)) { + const ipV6res = normalizeIPv6(host); if (ipV6res.isIPV6 === true) { host = `[${ipV6res.escapedHost}]`; } else { - host = components.host; + host = reescapeHostDelimiters(host, false); } } uriTokens.push(host); } - if (typeof components.port === "number" || typeof components.port === "string") { + if (typeof component.port === "number" || typeof component.port === "string") { uriTokens.push(":"); - uriTokens.push(String(components.port)); + uriTokens.push(String(component.port)); } return uriTokens.length ? uriTokens.join("") : void 0; } module2.exports = { + nonSimpleDomain, recomposeAuthority, - normalizeComponentEncoding, + reescapeHostDelimiters, + normalizePercentEncoding, + normalizePathEncoding, + escapePreservingEscapes, removeDotSegments, - normalizeIPv4, + isIPv4, + isUUID, normalizeIPv6, stringArrayToHexStripped }; @@ -67696,145 +67745,209 @@ var require_utils4 = __commonJS({ var require_schemes = __commonJS({ "node_modules/fast-uri/lib/schemes.js"(exports2, module2) { "use strict"; - var UUID_REG = /^[\da-f]{8}\b-[\da-f]{4}\b-[\da-f]{4}\b-[\da-f]{4}\b-[\da-f]{12}$/iu; + var { isUUID } = require_utils4(); var URN_REG = /([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu; - function isSecure(wsComponents) { - return typeof wsComponents.secure === "boolean" ? wsComponents.secure : String(wsComponents.scheme).toLowerCase() === "wss"; + var supportedSchemeNames = ( + /** @type {const} */ + [ + "http", + "https", + "ws", + "wss", + "urn", + "urn:uuid" + ] + ); + function isValidSchemeName(name) { + return supportedSchemeNames.indexOf( + /** @type {*} */ + name + ) !== -1; + } + function wsIsSecure(wsComponent) { + if (wsComponent.secure === true) { + return true; + } else if (wsComponent.secure === false) { + return false; + } else if (wsComponent.scheme) { + return wsComponent.scheme.length === 3 && (wsComponent.scheme[0] === "w" || wsComponent.scheme[0] === "W") && (wsComponent.scheme[1] === "s" || wsComponent.scheme[1] === "S") && (wsComponent.scheme[2] === "s" || wsComponent.scheme[2] === "S"); + } else { + return false; + } } - function httpParse(components) { - if (!components.host) { - components.error = components.error || "HTTP URIs must have a host."; + function httpParse(component) { + if (!component.host) { + component.error = component.error || "HTTP URIs must have a host."; } - return components; + return component; } - function httpSerialize(components) { - const secure = String(components.scheme).toLowerCase() === "https"; - if (components.port === (secure ? 443 : 80) || components.port === "") { - components.port = void 0; + function httpSerialize(component) { + const secure = String(component.scheme).toLowerCase() === "https"; + if (component.port === (secure ? 443 : 80) || component.port === "") { + component.port = void 0; } - if (!components.path) { - components.path = "/"; + if (!component.path) { + component.path = "/"; } - return components; + return component; } - function wsParse(wsComponents) { - wsComponents.secure = isSecure(wsComponents); - wsComponents.resourceName = (wsComponents.path || "/") + (wsComponents.query ? "?" + wsComponents.query : ""); - wsComponents.path = void 0; - wsComponents.query = void 0; - return wsComponents; + function wsParse(wsComponent) { + wsComponent.secure = wsIsSecure(wsComponent); + wsComponent.resourceName = (wsComponent.path || "/") + (wsComponent.query ? "?" + wsComponent.query : ""); + wsComponent.path = void 0; + wsComponent.query = void 0; + return wsComponent; } - function wsSerialize(wsComponents) { - if (wsComponents.port === (isSecure(wsComponents) ? 443 : 80) || wsComponents.port === "") { - wsComponents.port = void 0; + function wsSerialize(wsComponent) { + if (wsComponent.port === (wsIsSecure(wsComponent) ? 443 : 80) || wsComponent.port === "") { + wsComponent.port = void 0; } - if (typeof wsComponents.secure === "boolean") { - wsComponents.scheme = wsComponents.secure ? "wss" : "ws"; - wsComponents.secure = void 0; + if (typeof wsComponent.secure === "boolean") { + wsComponent.scheme = wsComponent.secure ? "wss" : "ws"; + wsComponent.secure = void 0; } - if (wsComponents.resourceName) { - const [path8, query] = wsComponents.resourceName.split("?"); - wsComponents.path = path8 && path8 !== "/" ? path8 : void 0; - wsComponents.query = query; - wsComponents.resourceName = void 0; + if (wsComponent.resourceName) { + const [path8, query] = wsComponent.resourceName.split("?"); + wsComponent.path = path8 && path8 !== "/" ? path8 : void 0; + wsComponent.query = query; + wsComponent.resourceName = void 0; } - wsComponents.fragment = void 0; - return wsComponents; + wsComponent.fragment = void 0; + return wsComponent; } - function urnParse(urnComponents, options) { - if (!urnComponents.path) { - urnComponents.error = "URN can not be parsed"; - return urnComponents; + function urnParse(urnComponent, options) { + if (!urnComponent.path) { + urnComponent.error = "URN can not be parsed"; + return urnComponent; } - const matches = urnComponents.path.match(URN_REG); + const matches = urnComponent.path.match(URN_REG); if (matches) { - const scheme = options.scheme || urnComponents.scheme || "urn"; - urnComponents.nid = matches[1].toLowerCase(); - urnComponents.nss = matches[2]; - const urnScheme = `${scheme}:${options.nid || urnComponents.nid}`; - const schemeHandler = SCHEMES[urnScheme]; - urnComponents.path = void 0; + const scheme = options.scheme || urnComponent.scheme || "urn"; + urnComponent.nid = matches[1].toLowerCase(); + urnComponent.nss = matches[2]; + const urnScheme = `${scheme}:${options.nid || urnComponent.nid}`; + const schemeHandler = getSchemeHandler(urnScheme); + urnComponent.path = void 0; if (schemeHandler) { - urnComponents = schemeHandler.parse(urnComponents, options); + urnComponent = schemeHandler.parse(urnComponent, options); } } else { - urnComponents.error = urnComponents.error || "URN can not be parsed."; + urnComponent.error = urnComponent.error || "URN can not be parsed."; } - return urnComponents; + return urnComponent; } - function urnSerialize(urnComponents, options) { - const scheme = options.scheme || urnComponents.scheme || "urn"; - const nid = urnComponents.nid.toLowerCase(); + function urnSerialize(urnComponent, options) { + if (urnComponent.nid === void 0) { + throw new Error("URN without nid cannot be serialized"); + } + const scheme = options.scheme || urnComponent.scheme || "urn"; + const nid = urnComponent.nid.toLowerCase(); const urnScheme = `${scheme}:${options.nid || nid}`; - const schemeHandler = SCHEMES[urnScheme]; + const schemeHandler = getSchemeHandler(urnScheme); if (schemeHandler) { - urnComponents = schemeHandler.serialize(urnComponents, options); + urnComponent = schemeHandler.serialize(urnComponent, options); } - const uriComponents = urnComponents; - const nss = urnComponents.nss; - uriComponents.path = `${nid || options.nid}:${nss}`; + const uriComponent = urnComponent; + const nss = urnComponent.nss; + uriComponent.path = `${nid || options.nid}:${nss}`; options.skipEscape = true; - return uriComponents; - } - function urnuuidParse(urnComponents, options) { - const uuidComponents = urnComponents; - uuidComponents.uuid = uuidComponents.nss; - uuidComponents.nss = void 0; - if (!options.tolerant && (!uuidComponents.uuid || !UUID_REG.test(uuidComponents.uuid))) { - uuidComponents.error = uuidComponents.error || "UUID is not valid."; - } - return uuidComponents; - } - function urnuuidSerialize(uuidComponents) { - const urnComponents = uuidComponents; - urnComponents.nss = (uuidComponents.uuid || "").toLowerCase(); - return urnComponents; - } - var http2 = { - scheme: "http", - domainHost: true, - parse: httpParse, - serialize: httpSerialize - }; - var https2 = { - scheme: "https", - domainHost: http2.domainHost, - parse: httpParse, - serialize: httpSerialize - }; - var ws = { - scheme: "ws", - domainHost: true, - parse: wsParse, - serialize: wsSerialize - }; - var wss = { - scheme: "wss", - domainHost: ws.domainHost, - parse: ws.parse, - serialize: ws.serialize - }; - var urn = { - scheme: "urn", - parse: urnParse, - serialize: urnSerialize, - skipNormalize: true - }; - var urnuuid = { - scheme: "urn:uuid", - parse: urnuuidParse, - serialize: urnuuidSerialize, - skipNormalize: true - }; - var SCHEMES = { - http: http2, - https: https2, - ws, - wss, - urn, - "urn:uuid": urnuuid - }; - module2.exports = SCHEMES; + return uriComponent; + } + function urnuuidParse(urnComponent, options) { + const uuidComponent = urnComponent; + uuidComponent.uuid = uuidComponent.nss; + uuidComponent.nss = void 0; + if (!options.tolerant && (!uuidComponent.uuid || !isUUID(uuidComponent.uuid))) { + uuidComponent.error = uuidComponent.error || "UUID is not valid."; + } + return uuidComponent; + } + function urnuuidSerialize(uuidComponent) { + const urnComponent = uuidComponent; + urnComponent.nss = (uuidComponent.uuid || "").toLowerCase(); + return urnComponent; + } + var http2 = ( + /** @type {SchemeHandler} */ + { + scheme: "http", + domainHost: true, + parse: httpParse, + serialize: httpSerialize + } + ); + var https2 = ( + /** @type {SchemeHandler} */ + { + scheme: "https", + domainHost: http2.domainHost, + parse: httpParse, + serialize: httpSerialize + } + ); + var ws = ( + /** @type {SchemeHandler} */ + { + scheme: "ws", + domainHost: true, + parse: wsParse, + serialize: wsSerialize + } + ); + var wss = ( + /** @type {SchemeHandler} */ + { + scheme: "wss", + domainHost: ws.domainHost, + parse: ws.parse, + serialize: ws.serialize + } + ); + var urn = ( + /** @type {SchemeHandler} */ + { + scheme: "urn", + parse: urnParse, + serialize: urnSerialize, + skipNormalize: true + } + ); + var urnuuid = ( + /** @type {SchemeHandler} */ + { + scheme: "urn:uuid", + parse: urnuuidParse, + serialize: urnuuidSerialize, + skipNormalize: true + } + ); + var SCHEMES = ( + /** @type {Record} */ + { + http: http2, + https: https2, + ws, + wss, + urn, + "urn:uuid": urnuuid + } + ); + Object.setPrototypeOf(SCHEMES, null); + function getSchemeHandler(scheme) { + return scheme && (SCHEMES[ + /** @type {SchemeName} */ + scheme + ] || SCHEMES[ + /** @type {SchemeName} */ + scheme.toLowerCase() + ]) || void 0; + } + module2.exports = { + wsIsSecure, + SCHEMES, + isValidSchemeName, + getSchemeHandler + }; } }); @@ -67842,22 +67955,25 @@ var require_schemes = __commonJS({ var require_fast_uri = __commonJS({ "node_modules/fast-uri/index.js"(exports2, module2) { "use strict"; - var { normalizeIPv6, normalizeIPv4, removeDotSegments, recomposeAuthority, normalizeComponentEncoding } = require_utils4(); - var SCHEMES = require_schemes(); + var { normalizeIPv6, removeDotSegments, recomposeAuthority, normalizePercentEncoding, normalizePathEncoding, escapePreservingEscapes, reescapeHostDelimiters, isIPv4, nonSimpleDomain } = require_utils4(); + var { SCHEMES, getSchemeHandler } = require_schemes(); function normalize(uri, options) { if (typeof uri === "string") { - uri = serialize(parse3(uri, options), options); + uri = /** @type {T} */ + normalizeString(uri, options); } else if (typeof uri === "object") { - uri = parse3(serialize(uri, options), options); + uri = /** @type {T} */ + parse3(serialize(uri, options), options); } return uri; } function resolve2(baseURI, relativeURI, options) { - const schemelessOptions = Object.assign({ scheme: "null" }, options); - const resolved = resolveComponents(parse3(baseURI, schemelessOptions), parse3(relativeURI, schemelessOptions), schemelessOptions, true); - return serialize(resolved, { ...schemelessOptions, skipEscape: true }); + const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" }; + const resolved = resolveComponent(parse3(baseURI, schemelessOptions), parse3(relativeURI, schemelessOptions), schemelessOptions, true); + schemelessOptions.skipEscape = true; + return serialize(resolved, schemelessOptions); } - function resolveComponents(base, relative2, options, skipNormalization) { + function resolveComponent(base, relative2, options, skipNormalization) { const target = {}; if (!skipNormalization) { base = parse3(serialize(base, options), options); @@ -67887,7 +68003,7 @@ var require_fast_uri = __commonJS({ target.query = base.query; } } else { - if (relative2.path.charAt(0) === "/") { + if (relative2.path[0] === "/") { target.path = removeDotSegments(relative2.path); } else { if ((base.userinfo !== void 0 || base.host !== void 0 || base.port !== void 0) && !base.path) { @@ -67911,22 +68027,12 @@ var require_fast_uri = __commonJS({ return target; } function equal(uriA, uriB, options) { - if (typeof uriA === "string") { - uriA = unescape(uriA); - uriA = serialize(normalizeComponentEncoding(parse3(uriA, options), true), { ...options, skipEscape: true }); - } else if (typeof uriA === "object") { - uriA = serialize(normalizeComponentEncoding(uriA, true), { ...options, skipEscape: true }); - } - if (typeof uriB === "string") { - uriB = unescape(uriB); - uriB = serialize(normalizeComponentEncoding(parse3(uriB, options), true), { ...options, skipEscape: true }); - } else if (typeof uriB === "object") { - uriB = serialize(normalizeComponentEncoding(uriB, true), { ...options, skipEscape: true }); - } - return uriA.toLowerCase() === uriB.toLowerCase(); + const normalizedA = normalizeComparableURI(uriA, options); + const normalizedB = normalizeComparableURI(uriB, options); + return normalizedA !== void 0 && normalizedB !== void 0 && normalizedA.toLowerCase() === normalizedB.toLowerCase(); } function serialize(cmpts, opts) { - const components = { + const component = { host: cmpts.host, scheme: cmpts.scheme, userinfo: cmpts.userinfo, @@ -67944,62 +68050,60 @@ var require_fast_uri = __commonJS({ }; const options = Object.assign({}, opts); const uriTokens = []; - const schemeHandler = SCHEMES[(options.scheme || components.scheme || "").toLowerCase()]; - if (schemeHandler && schemeHandler.serialize) schemeHandler.serialize(components, options); - if (components.path !== void 0) { + const schemeHandler = getSchemeHandler(options.scheme || component.scheme); + if (schemeHandler && schemeHandler.serialize) schemeHandler.serialize(component, options); + if (component.path !== void 0) { if (!options.skipEscape) { - components.path = escape(components.path); - if (components.scheme !== void 0) { - components.path = components.path.split("%3A").join(":"); + component.path = escapePreservingEscapes(component.path); + if (component.scheme !== void 0) { + component.path = component.path.split("%3A").join(":"); } } else { - components.path = unescape(components.path); + component.path = normalizePercentEncoding(component.path); } } - if (options.reference !== "suffix" && components.scheme) { - uriTokens.push(components.scheme, ":"); + if (options.reference !== "suffix" && component.scheme) { + uriTokens.push(component.scheme, ":"); } - const authority = recomposeAuthority(components, options); + const authority = recomposeAuthority(component); if (authority !== void 0) { if (options.reference !== "suffix") { uriTokens.push("//"); } uriTokens.push(authority); - if (components.path && components.path.charAt(0) !== "/") { + if (component.path && component.path[0] !== "/") { uriTokens.push("/"); } } - if (components.path !== void 0) { - let s = components.path; + if (component.path !== void 0) { + let s = component.path; if (!options.absolutePath && (!schemeHandler || !schemeHandler.absolutePath)) { s = removeDotSegments(s); } - if (authority === void 0) { - s = s.replace(/^\/\//u, "/%2F"); + if (authority === void 0 && s[0] === "/" && s[1] === "/") { + s = "/%2F" + s.slice(2); } uriTokens.push(s); } - if (components.query !== void 0) { - uriTokens.push("?", components.query); + if (component.query !== void 0) { + uriTokens.push("?", component.query); } - if (components.fragment !== void 0) { - uriTokens.push("#", components.fragment); + if (component.fragment !== void 0) { + uriTokens.push("#", component.fragment); } return uriTokens.join(""); } - var hexLookUp = Array.from({ length: 127 }, (v, k) => /[^!"$&'()*+,\-.;=_`a-z{}~]/u.test(String.fromCharCode(k))); - function nonSimpleDomain(value) { - let code = 0; - for (let i = 0, len = value.length; i < len; ++i) { - code = value.charCodeAt(i); - if (code > 126 || hexLookUp[code]) { - return true; - } + var URI_PARSE = /^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u; + function getParseError(parsed, matches) { + if (matches[2] !== void 0 && parsed.path && parsed.path[0] !== "/") { + return 'URI path must start with "/" when authority is present.'; } - return false; + if (typeof parsed.port === "number" && (parsed.port < 0 || parsed.port > 65535)) { + return "URI port is malformed."; + } + return void 0; } - var URI_PARSE = /^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u; - function parse3(uri, opts) { + function parseWithStatus(uri, opts) { const options = Object.assign({}, opts); const parsed = { scheme: void 0, @@ -68010,9 +68114,15 @@ var require_fast_uri = __commonJS({ query: void 0, fragment: void 0 }; - const gotEncoding = uri.indexOf("%") !== -1; + let malformedAuthorityOrPort = false; let isIP = false; - if (options.reference === "suffix") uri = (options.scheme ? options.scheme + ":" : "") + "//" + uri; + if (options.reference === "suffix") { + if (options.scheme) { + uri = options.scheme + ":" + uri; + } else { + uri = "//" + uri; + } + } const matches = uri.match(URI_PARSE); if (matches) { parsed.scheme = matches[1]; @@ -68025,18 +68135,22 @@ var require_fast_uri = __commonJS({ if (isNaN(parsed.port)) { parsed.port = matches[5]; } + const parseError = getParseError(parsed, matches); + if (parseError !== void 0) { + parsed.error = parsed.error || parseError; + malformedAuthorityOrPort = true; + } if (parsed.host) { - const ipv4result = normalizeIPv4(parsed.host); - if (ipv4result.isIPV4 === false) { - const ipv6result = normalizeIPv6(ipv4result.host, { isIPV4: false }); + const ipv4result = isIPv4(parsed.host); + if (ipv4result === false) { + const ipv6result = normalizeIPv6(parsed.host); parsed.host = ipv6result.host.toLowerCase(); isIP = ipv6result.isIPV6; } else { - parsed.host = ipv4result.host; isIP = true; } } - if (parsed.scheme === void 0 && parsed.userinfo === void 0 && parsed.host === void 0 && parsed.port === void 0 && !parsed.path && parsed.query === void 0) { + if (parsed.scheme === void 0 && parsed.userinfo === void 0 && parsed.host === void 0 && parsed.port === void 0 && parsed.query === void 0 && !parsed.path) { parsed.reference = "same-document"; } else if (parsed.scheme === void 0) { parsed.reference = "relative"; @@ -68048,7 +68162,7 @@ var require_fast_uri = __commonJS({ if (options.reference && options.reference !== "suffix" && options.reference !== parsed.reference) { parsed.error = parsed.error || "URI is not a " + options.reference + " reference."; } - const schemeHandler = SCHEMES[(options.scheme || parsed.scheme || "").toLowerCase()]; + const schemeHandler = getSchemeHandler(options.scheme || parsed.scheme); if (!options.unicodeSupport && (!schemeHandler || !schemeHandler.unicodeSupport)) { if (parsed.host && (options.domainHost || schemeHandler && schemeHandler.domainHost) && isIP === false && nonSimpleDomain(parsed.host)) { try { @@ -68059,17 +68173,23 @@ var require_fast_uri = __commonJS({ } } if (!schemeHandler || schemeHandler && !schemeHandler.skipNormalize) { - if (gotEncoding && parsed.scheme !== void 0) { - parsed.scheme = unescape(parsed.scheme); - } - if (gotEncoding && parsed.host !== void 0) { - parsed.host = unescape(parsed.host); + if (uri.indexOf("%") !== -1) { + if (parsed.scheme !== void 0) { + parsed.scheme = unescape(parsed.scheme); + } + if (parsed.host !== void 0) { + parsed.host = reescapeHostDelimiters(unescape(parsed.host), isIP); + } } - if (parsed.path !== void 0 && parsed.path.length) { - parsed.path = escape(unescape(parsed.path)); + if (parsed.path) { + parsed.path = normalizePathEncoding(parsed.path); } - if (parsed.fragment !== void 0 && parsed.fragment.length) { - parsed.fragment = encodeURI(decodeURIComponent(parsed.fragment)); + if (parsed.fragment) { + try { + parsed.fragment = encodeURI(decodeURIComponent(parsed.fragment)); + } catch { + parsed.error = parsed.error || "URI malformed"; + } } } if (schemeHandler && schemeHandler.parse) { @@ -68078,13 +68198,35 @@ var require_fast_uri = __commonJS({ } else { parsed.error = parsed.error || "URI can not be parsed."; } - return parsed; + return { parsed, malformedAuthorityOrPort }; + } + function parse3(uri, opts) { + return parseWithStatus(uri, opts).parsed; + } + function normalizeString(uri, opts) { + return normalizeStringWithStatus(uri, opts).normalized; + } + function normalizeStringWithStatus(uri, opts) { + const { parsed, malformedAuthorityOrPort } = parseWithStatus(uri, opts); + return { + normalized: malformedAuthorityOrPort ? uri : serialize(parsed, opts), + malformedAuthorityOrPort + }; + } + function normalizeComparableURI(uri, opts) { + if (typeof uri === "string") { + const { normalized, malformedAuthorityOrPort } = normalizeStringWithStatus(uri, opts); + return malformedAuthorityOrPort ? void 0 : normalized; + } + if (typeof uri === "object") { + return serialize(uri, opts); + } } var fastUri = { SCHEMES, normalize, resolve: resolve2, - resolveComponents, + resolveComponent, equal, serialize, parse: parse3 diff --git a/dist/update-repo-task-status.js b/dist/update-repo-task-status.js index fff8f286..94d27857 100644 --- a/dist/update-repo-task-status.js +++ b/dist/update-repo-task-status.js @@ -21586,91 +21586,65 @@ var require_data = __commonJS({ } }); -// node_modules/fast-uri/lib/scopedChars.js -var require_scopedChars = __commonJS({ - "node_modules/fast-uri/lib/scopedChars.js"(exports2, module2) { - "use strict"; - var HEX = { - 0: 0, - 1: 1, - 2: 2, - 3: 3, - 4: 4, - 5: 5, - 6: 6, - 7: 7, - 8: 8, - 9: 9, - a: 10, - A: 10, - b: 11, - B: 11, - c: 12, - C: 12, - d: 13, - D: 13, - e: 14, - E: 14, - f: 15, - F: 15 - }; - module2.exports = { - HEX - }; - } -}); - // node_modules/fast-uri/lib/utils.js var require_utils2 = __commonJS({ "node_modules/fast-uri/lib/utils.js"(exports2, module2) { "use strict"; - var { HEX } = require_scopedChars(); - function normalizeIPv4(host) { - if (findToken(host, ".") < 3) { - return { host, isIPV4: false }; + var isUUID = RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu); + var isIPv4 = RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u); + var isHexPair = RegExp.prototype.test.bind(/^[\da-f]{2}$/iu); + var isUnreserved = RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu); + var isPathCharacter = RegExp.prototype.test.bind(/^[\da-z\-._~!$&'()*+,;=:@/]$/iu); + function stringArrayToHexStripped(input) { + let acc = ""; + let code = 0; + let i = 0; + for (i = 0; i < input.length; i++) { + code = input[i].charCodeAt(0); + if (code === 48) { + continue; + } + if (!(code >= 48 && code <= 57 || code >= 65 && code <= 70 || code >= 97 && code <= 102)) { + return ""; + } + acc += input[i]; + break; } - const matches = host.match(/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/u) || []; - const [address] = matches; - if (address) { - return { host: stripLeadingZeros(address, "."), isIPV4: true }; - } else { - return { host, isIPV4: false }; + for (i += 1; i < input.length; i++) { + code = input[i].charCodeAt(0); + if (!(code >= 48 && code <= 57 || code >= 65 && code <= 70 || code >= 97 && code <= 102)) { + return ""; + } + acc += input[i]; } + return acc; } - function stringArrayToHexStripped(input, keepZero = false) { - let acc = ""; - let strip = true; - for (const c of input) { - if (HEX[c] === void 0) return void 0; - if (c !== "0" && strip === true) strip = false; - if (!strip) acc += c; + var nonSimpleDomain = RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u); + function consumeIsZone(buffer) { + buffer.length = 0; + return true; + } + function consumeHextets(buffer, address, output) { + if (buffer.length) { + const hex = stringArrayToHexStripped(buffer); + if (hex !== "") { + address.push(hex); + } else { + output.error = true; + return false; + } + buffer.length = 0; } - if (keepZero && acc.length === 0) acc = "0"; - return acc; + return true; } function getIPV6(input) { let tokenCount = 0; const output = { error: false, address: "", zone: "" }; const address = []; const buffer = []; - let isZone = false; let endipv6Encountered = false; let endIpv6 = false; - function consume() { - if (buffer.length) { - if (isZone === false) { - const hex = stringArrayToHexStripped(buffer); - if (hex !== void 0) { - address.push(hex); - } else { - output.error = true; - return false; - } - } - buffer.length = 0; - } - return true; - } + let consume = consumeHextets; for (let i = 0; i < input.length; i++) { const cursor = input[i]; if (cursor === "[" || cursor === "]") { @@ -21680,31 +21654,30 @@ var require_utils2 = __commonJS({ if (endipv6Encountered === true) { endIpv6 = true; } - if (!consume()) { + if (!consume(buffer, address, output)) { break; } - tokenCount++; - address.push(":"); - if (tokenCount > 7) { + if (++tokenCount > 7) { output.error = true; break; } - if (i - 1 >= 0 && input[i - 1] === ":") { + if (i > 0 && input[i - 1] === ":") { endipv6Encountered = true; } + address.push(":"); continue; } else if (cursor === "%") { - if (!consume()) { + if (!consume(buffer, address, output)) { break; } - isZone = true; + consume = consumeIsZone; } else { buffer.push(cursor); continue; } } if (buffer.length) { - if (isZone) { + if (consume === consumeIsZone) { output.zone = buffer.join(""); } else if (endIpv6) { address.push(buffer.join("")); @@ -21715,7 +21688,7 @@ var require_utils2 = __commonJS({ output.address = address.join(""); return output; } - function normalizeIPv6(host, opts = {}) { + function normalizeIPv6(host) { if (findToken(host, ":") < 2) { return { host, isIPV6: false }; } @@ -21727,33 +21700,11 @@ var require_utils2 = __commonJS({ newHost += "%" + ipv6.zone; escapedHost += "%25" + ipv6.zone; } - return { host: newHost, escapedHost, isIPV6: true }; + return { host: newHost, isIPV6: true, escapedHost }; } else { return { host, isIPV6: false }; } } - function stripLeadingZeros(str, token) { - let out = ""; - let skip = true; - const l = str.length; - for (let i = 0; i < l; i++) { - const c = str[i]; - if (c === "0" && skip) { - if (i + 1 <= l && str[i + 1] === token || i + 1 === l) { - out += c; - skip = false; - } - } else { - if (c === token) { - skip = true; - } else { - skip = false; - } - out += c; - } - } - return out; - } function findToken(str, token) { let ind = 0; for (let i = 0; i < str.length; i++) { @@ -21761,89 +21712,187 @@ var require_utils2 = __commonJS({ } return ind; } - var RDS1 = /^\.\.?\//u; - var RDS2 = /^\/\.(?:\/|$)/u; - var RDS3 = /^\/\.\.(?:\/|$)/u; - var RDS5 = /^\/?(?:.|\n)*?(?=\/|$)/u; - function removeDotSegments(input) { + function removeDotSegments(path) { + let input = path; const output = []; - while (input.length) { - if (input.match(RDS1)) { - input = input.replace(RDS1, ""); - } else if (input.match(RDS2)) { - input = input.replace(RDS2, "/"); - } else if (input.match(RDS3)) { - input = input.replace(RDS3, "/"); - output.pop(); - } else if (input === "." || input === "..") { - input = ""; - } else { - const im = input.match(RDS5); - if (im) { - const s = im[0]; - input = input.slice(s.length); - output.push(s); + let nextSlash = -1; + let len = 0; + while (len = input.length) { + if (len === 1) { + if (input === ".") { + break; + } else if (input === "/") { + output.push("/"); + break; } else { - throw new Error("Unexpected dot segment condition"); + output.push(input); + break; + } + } else if (len === 2) { + if (input[0] === ".") { + if (input[1] === ".") { + break; + } else if (input[1] === "/") { + input = input.slice(2); + continue; + } + } else if (input[0] === "/") { + if (input[1] === "." || input[1] === "/") { + output.push("/"); + break; + } + } + } else if (len === 3) { + if (input === "/..") { + if (output.length !== 0) { + output.pop(); + } + output.push("/"); + break; } } + if (input[0] === ".") { + if (input[1] === ".") { + if (input[2] === "/") { + input = input.slice(3); + continue; + } + } else if (input[1] === "/") { + input = input.slice(2); + continue; + } + } else if (input[0] === "/") { + if (input[1] === ".") { + if (input[2] === "/") { + input = input.slice(2); + continue; + } else if (input[2] === ".") { + if (input[3] === "/") { + input = input.slice(3); + if (output.length !== 0) { + output.pop(); + } + continue; + } + } + } + } + if ((nextSlash = input.indexOf("/", 1)) === -1) { + output.push(input); + break; + } else { + output.push(input.slice(0, nextSlash)); + input = input.slice(nextSlash); + } } return output.join(""); } - function normalizeComponentEncoding(components, esc) { - const func = esc !== true ? escape : unescape; - if (components.scheme !== void 0) { - components.scheme = func(components.scheme); - } - if (components.userinfo !== void 0) { - components.userinfo = func(components.userinfo); - } - if (components.host !== void 0) { - components.host = func(components.host); + var HOST_DELIMS = { "@": "%40", "/": "%2F", "?": "%3F", "#": "%23", ":": "%3A" }; + var HOST_DELIM_RE = /[@/?#:]/g; + var HOST_DELIM_NO_COLON_RE = /[@/?#]/g; + function reescapeHostDelimiters(host, isIP) { + const re = isIP ? HOST_DELIM_NO_COLON_RE : HOST_DELIM_RE; + re.lastIndex = 0; + return host.replace(re, (ch) => HOST_DELIMS[ch]); + } + function normalizePercentEncoding(input, decodeUnreserved = false) { + if (input.indexOf("%") === -1) { + return input; } - if (components.path !== void 0) { - components.path = func(components.path); + let output = ""; + for (let i = 0; i < input.length; i++) { + if (input[i] === "%" && i + 2 < input.length) { + const hex = input.slice(i + 1, i + 3); + if (isHexPair(hex)) { + const normalizedHex = hex.toUpperCase(); + const decoded = String.fromCharCode(parseInt(normalizedHex, 16)); + if (decodeUnreserved && isUnreserved(decoded)) { + output += decoded; + } else { + output += "%" + normalizedHex; + } + i += 2; + continue; + } + } + output += input[i]; } - if (components.query !== void 0) { - components.query = func(components.query); + return output; + } + function normalizePathEncoding(input) { + let output = ""; + for (let i = 0; i < input.length; i++) { + if (input[i] === "%" && i + 2 < input.length) { + const hex = input.slice(i + 1, i + 3); + if (isHexPair(hex)) { + const normalizedHex = hex.toUpperCase(); + const decoded = String.fromCharCode(parseInt(normalizedHex, 16)); + if (decoded !== "." && isUnreserved(decoded)) { + output += decoded; + } else { + output += "%" + normalizedHex; + } + i += 2; + continue; + } + } + if (isPathCharacter(input[i])) { + output += input[i]; + } else { + output += escape(input[i]); + } } - if (components.fragment !== void 0) { - components.fragment = func(components.fragment); + return output; + } + function escapePreservingEscapes(input) { + let output = ""; + for (let i = 0; i < input.length; i++) { + if (input[i] === "%" && i + 2 < input.length) { + const hex = input.slice(i + 1, i + 3); + if (isHexPair(hex)) { + output += "%" + hex.toUpperCase(); + i += 2; + continue; + } + } + output += escape(input[i]); } - return components; + return output; } - function recomposeAuthority(components, options) { + function recomposeAuthority(component) { const uriTokens = []; - if (components.userinfo !== void 0) { - uriTokens.push(components.userinfo); + if (component.userinfo !== void 0) { + uriTokens.push(component.userinfo); uriTokens.push("@"); } - if (components.host !== void 0) { - let host = unescape(components.host); - const ipV4res = normalizeIPv4(host); - if (ipV4res.isIPV4) { - host = ipV4res.host; - } else { - const ipV6res = normalizeIPv6(ipV4res.host, { isIPV4: false }); + if (component.host !== void 0) { + let host = unescape(component.host); + if (!isIPv4(host)) { + const ipV6res = normalizeIPv6(host); if (ipV6res.isIPV6 === true) { host = `[${ipV6res.escapedHost}]`; } else { - host = components.host; + host = reescapeHostDelimiters(host, false); } } uriTokens.push(host); } - if (typeof components.port === "number" || typeof components.port === "string") { + if (typeof component.port === "number" || typeof component.port === "string") { uriTokens.push(":"); - uriTokens.push(String(components.port)); + uriTokens.push(String(component.port)); } return uriTokens.length ? uriTokens.join("") : void 0; } module2.exports = { + nonSimpleDomain, recomposeAuthority, - normalizeComponentEncoding, + reescapeHostDelimiters, + normalizePercentEncoding, + normalizePathEncoding, + escapePreservingEscapes, removeDotSegments, - normalizeIPv4, + isIPv4, + isUUID, normalizeIPv6, stringArrayToHexStripped }; @@ -21854,145 +21903,209 @@ var require_utils2 = __commonJS({ var require_schemes = __commonJS({ "node_modules/fast-uri/lib/schemes.js"(exports2, module2) { "use strict"; - var UUID_REG = /^[\da-f]{8}\b-[\da-f]{4}\b-[\da-f]{4}\b-[\da-f]{4}\b-[\da-f]{12}$/iu; + var { isUUID } = require_utils2(); var URN_REG = /([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu; - function isSecure(wsComponents) { - return typeof wsComponents.secure === "boolean" ? wsComponents.secure : String(wsComponents.scheme).toLowerCase() === "wss"; + var supportedSchemeNames = ( + /** @type {const} */ + [ + "http", + "https", + "ws", + "wss", + "urn", + "urn:uuid" + ] + ); + function isValidSchemeName(name) { + return supportedSchemeNames.indexOf( + /** @type {*} */ + name + ) !== -1; + } + function wsIsSecure(wsComponent) { + if (wsComponent.secure === true) { + return true; + } else if (wsComponent.secure === false) { + return false; + } else if (wsComponent.scheme) { + return wsComponent.scheme.length === 3 && (wsComponent.scheme[0] === "w" || wsComponent.scheme[0] === "W") && (wsComponent.scheme[1] === "s" || wsComponent.scheme[1] === "S") && (wsComponent.scheme[2] === "s" || wsComponent.scheme[2] === "S"); + } else { + return false; + } } - function httpParse(components) { - if (!components.host) { - components.error = components.error || "HTTP URIs must have a host."; + function httpParse(component) { + if (!component.host) { + component.error = component.error || "HTTP URIs must have a host."; } - return components; + return component; } - function httpSerialize(components) { - const secure = String(components.scheme).toLowerCase() === "https"; - if (components.port === (secure ? 443 : 80) || components.port === "") { - components.port = void 0; + function httpSerialize(component) { + const secure = String(component.scheme).toLowerCase() === "https"; + if (component.port === (secure ? 443 : 80) || component.port === "") { + component.port = void 0; } - if (!components.path) { - components.path = "/"; + if (!component.path) { + component.path = "/"; } - return components; + return component; } - function wsParse(wsComponents) { - wsComponents.secure = isSecure(wsComponents); - wsComponents.resourceName = (wsComponents.path || "/") + (wsComponents.query ? "?" + wsComponents.query : ""); - wsComponents.path = void 0; - wsComponents.query = void 0; - return wsComponents; + function wsParse(wsComponent) { + wsComponent.secure = wsIsSecure(wsComponent); + wsComponent.resourceName = (wsComponent.path || "/") + (wsComponent.query ? "?" + wsComponent.query : ""); + wsComponent.path = void 0; + wsComponent.query = void 0; + return wsComponent; } - function wsSerialize(wsComponents) { - if (wsComponents.port === (isSecure(wsComponents) ? 443 : 80) || wsComponents.port === "") { - wsComponents.port = void 0; + function wsSerialize(wsComponent) { + if (wsComponent.port === (wsIsSecure(wsComponent) ? 443 : 80) || wsComponent.port === "") { + wsComponent.port = void 0; } - if (typeof wsComponents.secure === "boolean") { - wsComponents.scheme = wsComponents.secure ? "wss" : "ws"; - wsComponents.secure = void 0; + if (typeof wsComponent.secure === "boolean") { + wsComponent.scheme = wsComponent.secure ? "wss" : "ws"; + wsComponent.secure = void 0; } - if (wsComponents.resourceName) { - const [path, query] = wsComponents.resourceName.split("?"); - wsComponents.path = path && path !== "/" ? path : void 0; - wsComponents.query = query; - wsComponents.resourceName = void 0; + if (wsComponent.resourceName) { + const [path, query] = wsComponent.resourceName.split("?"); + wsComponent.path = path && path !== "/" ? path : void 0; + wsComponent.query = query; + wsComponent.resourceName = void 0; } - wsComponents.fragment = void 0; - return wsComponents; + wsComponent.fragment = void 0; + return wsComponent; } - function urnParse(urnComponents, options) { - if (!urnComponents.path) { - urnComponents.error = "URN can not be parsed"; - return urnComponents; + function urnParse(urnComponent, options) { + if (!urnComponent.path) { + urnComponent.error = "URN can not be parsed"; + return urnComponent; } - const matches = urnComponents.path.match(URN_REG); + const matches = urnComponent.path.match(URN_REG); if (matches) { - const scheme = options.scheme || urnComponents.scheme || "urn"; - urnComponents.nid = matches[1].toLowerCase(); - urnComponents.nss = matches[2]; - const urnScheme = `${scheme}:${options.nid || urnComponents.nid}`; - const schemeHandler = SCHEMES[urnScheme]; - urnComponents.path = void 0; + const scheme = options.scheme || urnComponent.scheme || "urn"; + urnComponent.nid = matches[1].toLowerCase(); + urnComponent.nss = matches[2]; + const urnScheme = `${scheme}:${options.nid || urnComponent.nid}`; + const schemeHandler = getSchemeHandler(urnScheme); + urnComponent.path = void 0; if (schemeHandler) { - urnComponents = schemeHandler.parse(urnComponents, options); + urnComponent = schemeHandler.parse(urnComponent, options); } } else { - urnComponents.error = urnComponents.error || "URN can not be parsed."; + urnComponent.error = urnComponent.error || "URN can not be parsed."; } - return urnComponents; + return urnComponent; } - function urnSerialize(urnComponents, options) { - const scheme = options.scheme || urnComponents.scheme || "urn"; - const nid = urnComponents.nid.toLowerCase(); + function urnSerialize(urnComponent, options) { + if (urnComponent.nid === void 0) { + throw new Error("URN without nid cannot be serialized"); + } + const scheme = options.scheme || urnComponent.scheme || "urn"; + const nid = urnComponent.nid.toLowerCase(); const urnScheme = `${scheme}:${options.nid || nid}`; - const schemeHandler = SCHEMES[urnScheme]; + const schemeHandler = getSchemeHandler(urnScheme); if (schemeHandler) { - urnComponents = schemeHandler.serialize(urnComponents, options); + urnComponent = schemeHandler.serialize(urnComponent, options); } - const uriComponents = urnComponents; - const nss = urnComponents.nss; - uriComponents.path = `${nid || options.nid}:${nss}`; + const uriComponent = urnComponent; + const nss = urnComponent.nss; + uriComponent.path = `${nid || options.nid}:${nss}`; options.skipEscape = true; - return uriComponents; - } - function urnuuidParse(urnComponents, options) { - const uuidComponents = urnComponents; - uuidComponents.uuid = uuidComponents.nss; - uuidComponents.nss = void 0; - if (!options.tolerant && (!uuidComponents.uuid || !UUID_REG.test(uuidComponents.uuid))) { - uuidComponents.error = uuidComponents.error || "UUID is not valid."; - } - return uuidComponents; - } - function urnuuidSerialize(uuidComponents) { - const urnComponents = uuidComponents; - urnComponents.nss = (uuidComponents.uuid || "").toLowerCase(); - return urnComponents; - } - var http = { - scheme: "http", - domainHost: true, - parse: httpParse, - serialize: httpSerialize - }; - var https = { - scheme: "https", - domainHost: http.domainHost, - parse: httpParse, - serialize: httpSerialize - }; - var ws = { - scheme: "ws", - domainHost: true, - parse: wsParse, - serialize: wsSerialize - }; - var wss = { - scheme: "wss", - domainHost: ws.domainHost, - parse: ws.parse, - serialize: ws.serialize - }; - var urn = { - scheme: "urn", - parse: urnParse, - serialize: urnSerialize, - skipNormalize: true - }; - var urnuuid = { - scheme: "urn:uuid", - parse: urnuuidParse, - serialize: urnuuidSerialize, - skipNormalize: true - }; - var SCHEMES = { - http, - https, - ws, - wss, - urn, - "urn:uuid": urnuuid - }; - module2.exports = SCHEMES; + return uriComponent; + } + function urnuuidParse(urnComponent, options) { + const uuidComponent = urnComponent; + uuidComponent.uuid = uuidComponent.nss; + uuidComponent.nss = void 0; + if (!options.tolerant && (!uuidComponent.uuid || !isUUID(uuidComponent.uuid))) { + uuidComponent.error = uuidComponent.error || "UUID is not valid."; + } + return uuidComponent; + } + function urnuuidSerialize(uuidComponent) { + const urnComponent = uuidComponent; + urnComponent.nss = (uuidComponent.uuid || "").toLowerCase(); + return urnComponent; + } + var http = ( + /** @type {SchemeHandler} */ + { + scheme: "http", + domainHost: true, + parse: httpParse, + serialize: httpSerialize + } + ); + var https = ( + /** @type {SchemeHandler} */ + { + scheme: "https", + domainHost: http.domainHost, + parse: httpParse, + serialize: httpSerialize + } + ); + var ws = ( + /** @type {SchemeHandler} */ + { + scheme: "ws", + domainHost: true, + parse: wsParse, + serialize: wsSerialize + } + ); + var wss = ( + /** @type {SchemeHandler} */ + { + scheme: "wss", + domainHost: ws.domainHost, + parse: ws.parse, + serialize: ws.serialize + } + ); + var urn = ( + /** @type {SchemeHandler} */ + { + scheme: "urn", + parse: urnParse, + serialize: urnSerialize, + skipNormalize: true + } + ); + var urnuuid = ( + /** @type {SchemeHandler} */ + { + scheme: "urn:uuid", + parse: urnuuidParse, + serialize: urnuuidSerialize, + skipNormalize: true + } + ); + var SCHEMES = ( + /** @type {Record} */ + { + http, + https, + ws, + wss, + urn, + "urn:uuid": urnuuid + } + ); + Object.setPrototypeOf(SCHEMES, null); + function getSchemeHandler(scheme) { + return scheme && (SCHEMES[ + /** @type {SchemeName} */ + scheme + ] || SCHEMES[ + /** @type {SchemeName} */ + scheme.toLowerCase() + ]) || void 0; + } + module2.exports = { + wsIsSecure, + SCHEMES, + isValidSchemeName, + getSchemeHandler + }; } }); @@ -22000,22 +22113,25 @@ var require_schemes = __commonJS({ var require_fast_uri = __commonJS({ "node_modules/fast-uri/index.js"(exports2, module2) { "use strict"; - var { normalizeIPv6, normalizeIPv4, removeDotSegments, recomposeAuthority, normalizeComponentEncoding } = require_utils2(); - var SCHEMES = require_schemes(); + var { normalizeIPv6, removeDotSegments, recomposeAuthority, normalizePercentEncoding, normalizePathEncoding, escapePreservingEscapes, reescapeHostDelimiters, isIPv4, nonSimpleDomain } = require_utils2(); + var { SCHEMES, getSchemeHandler } = require_schemes(); function normalize(uri, options) { if (typeof uri === "string") { - uri = serialize(parse2(uri, options), options); + uri = /** @type {T} */ + normalizeString(uri, options); } else if (typeof uri === "object") { - uri = parse2(serialize(uri, options), options); + uri = /** @type {T} */ + parse2(serialize(uri, options), options); } return uri; } function resolve(baseURI, relativeURI, options) { - const schemelessOptions = Object.assign({ scheme: "null" }, options); - const resolved = resolveComponents(parse2(baseURI, schemelessOptions), parse2(relativeURI, schemelessOptions), schemelessOptions, true); - return serialize(resolved, { ...schemelessOptions, skipEscape: true }); + const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" }; + const resolved = resolveComponent(parse2(baseURI, schemelessOptions), parse2(relativeURI, schemelessOptions), schemelessOptions, true); + schemelessOptions.skipEscape = true; + return serialize(resolved, schemelessOptions); } - function resolveComponents(base, relative, options, skipNormalization) { + function resolveComponent(base, relative, options, skipNormalization) { const target = {}; if (!skipNormalization) { base = parse2(serialize(base, options), options); @@ -22045,7 +22161,7 @@ var require_fast_uri = __commonJS({ target.query = base.query; } } else { - if (relative.path.charAt(0) === "/") { + if (relative.path[0] === "/") { target.path = removeDotSegments(relative.path); } else { if ((base.userinfo !== void 0 || base.host !== void 0 || base.port !== void 0) && !base.path) { @@ -22069,22 +22185,12 @@ var require_fast_uri = __commonJS({ return target; } function equal(uriA, uriB, options) { - if (typeof uriA === "string") { - uriA = unescape(uriA); - uriA = serialize(normalizeComponentEncoding(parse2(uriA, options), true), { ...options, skipEscape: true }); - } else if (typeof uriA === "object") { - uriA = serialize(normalizeComponentEncoding(uriA, true), { ...options, skipEscape: true }); - } - if (typeof uriB === "string") { - uriB = unescape(uriB); - uriB = serialize(normalizeComponentEncoding(parse2(uriB, options), true), { ...options, skipEscape: true }); - } else if (typeof uriB === "object") { - uriB = serialize(normalizeComponentEncoding(uriB, true), { ...options, skipEscape: true }); - } - return uriA.toLowerCase() === uriB.toLowerCase(); + const normalizedA = normalizeComparableURI(uriA, options); + const normalizedB = normalizeComparableURI(uriB, options); + return normalizedA !== void 0 && normalizedB !== void 0 && normalizedA.toLowerCase() === normalizedB.toLowerCase(); } function serialize(cmpts, opts) { - const components = { + const component = { host: cmpts.host, scheme: cmpts.scheme, userinfo: cmpts.userinfo, @@ -22102,62 +22208,60 @@ var require_fast_uri = __commonJS({ }; const options = Object.assign({}, opts); const uriTokens = []; - const schemeHandler = SCHEMES[(options.scheme || components.scheme || "").toLowerCase()]; - if (schemeHandler && schemeHandler.serialize) schemeHandler.serialize(components, options); - if (components.path !== void 0) { + const schemeHandler = getSchemeHandler(options.scheme || component.scheme); + if (schemeHandler && schemeHandler.serialize) schemeHandler.serialize(component, options); + if (component.path !== void 0) { if (!options.skipEscape) { - components.path = escape(components.path); - if (components.scheme !== void 0) { - components.path = components.path.split("%3A").join(":"); + component.path = escapePreservingEscapes(component.path); + if (component.scheme !== void 0) { + component.path = component.path.split("%3A").join(":"); } } else { - components.path = unescape(components.path); + component.path = normalizePercentEncoding(component.path); } } - if (options.reference !== "suffix" && components.scheme) { - uriTokens.push(components.scheme, ":"); + if (options.reference !== "suffix" && component.scheme) { + uriTokens.push(component.scheme, ":"); } - const authority = recomposeAuthority(components, options); + const authority = recomposeAuthority(component); if (authority !== void 0) { if (options.reference !== "suffix") { uriTokens.push("//"); } uriTokens.push(authority); - if (components.path && components.path.charAt(0) !== "/") { + if (component.path && component.path[0] !== "/") { uriTokens.push("/"); } } - if (components.path !== void 0) { - let s = components.path; + if (component.path !== void 0) { + let s = component.path; if (!options.absolutePath && (!schemeHandler || !schemeHandler.absolutePath)) { s = removeDotSegments(s); } - if (authority === void 0) { - s = s.replace(/^\/\//u, "/%2F"); + if (authority === void 0 && s[0] === "/" && s[1] === "/") { + s = "/%2F" + s.slice(2); } uriTokens.push(s); } - if (components.query !== void 0) { - uriTokens.push("?", components.query); + if (component.query !== void 0) { + uriTokens.push("?", component.query); } - if (components.fragment !== void 0) { - uriTokens.push("#", components.fragment); + if (component.fragment !== void 0) { + uriTokens.push("#", component.fragment); } return uriTokens.join(""); } - var hexLookUp = Array.from({ length: 127 }, (v, k) => /[^!"$&'()*+,\-.;=_`a-z{}~]/u.test(String.fromCharCode(k))); - function nonSimpleDomain(value) { - let code = 0; - for (let i = 0, len = value.length; i < len; ++i) { - code = value.charCodeAt(i); - if (code > 126 || hexLookUp[code]) { - return true; - } + var URI_PARSE = /^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u; + function getParseError(parsed, matches) { + if (matches[2] !== void 0 && parsed.path && parsed.path[0] !== "/") { + return 'URI path must start with "/" when authority is present.'; } - return false; + if (typeof parsed.port === "number" && (parsed.port < 0 || parsed.port > 65535)) { + return "URI port is malformed."; + } + return void 0; } - var URI_PARSE = /^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u; - function parse2(uri, opts) { + function parseWithStatus(uri, opts) { const options = Object.assign({}, opts); const parsed = { scheme: void 0, @@ -22168,9 +22272,15 @@ var require_fast_uri = __commonJS({ query: void 0, fragment: void 0 }; - const gotEncoding = uri.indexOf("%") !== -1; + let malformedAuthorityOrPort = false; let isIP = false; - if (options.reference === "suffix") uri = (options.scheme ? options.scheme + ":" : "") + "//" + uri; + if (options.reference === "suffix") { + if (options.scheme) { + uri = options.scheme + ":" + uri; + } else { + uri = "//" + uri; + } + } const matches = uri.match(URI_PARSE); if (matches) { parsed.scheme = matches[1]; @@ -22183,18 +22293,22 @@ var require_fast_uri = __commonJS({ if (isNaN(parsed.port)) { parsed.port = matches[5]; } + const parseError = getParseError(parsed, matches); + if (parseError !== void 0) { + parsed.error = parsed.error || parseError; + malformedAuthorityOrPort = true; + } if (parsed.host) { - const ipv4result = normalizeIPv4(parsed.host); - if (ipv4result.isIPV4 === false) { - const ipv6result = normalizeIPv6(ipv4result.host, { isIPV4: false }); + const ipv4result = isIPv4(parsed.host); + if (ipv4result === false) { + const ipv6result = normalizeIPv6(parsed.host); parsed.host = ipv6result.host.toLowerCase(); isIP = ipv6result.isIPV6; } else { - parsed.host = ipv4result.host; isIP = true; } } - if (parsed.scheme === void 0 && parsed.userinfo === void 0 && parsed.host === void 0 && parsed.port === void 0 && !parsed.path && parsed.query === void 0) { + if (parsed.scheme === void 0 && parsed.userinfo === void 0 && parsed.host === void 0 && parsed.port === void 0 && parsed.query === void 0 && !parsed.path) { parsed.reference = "same-document"; } else if (parsed.scheme === void 0) { parsed.reference = "relative"; @@ -22206,7 +22320,7 @@ var require_fast_uri = __commonJS({ if (options.reference && options.reference !== "suffix" && options.reference !== parsed.reference) { parsed.error = parsed.error || "URI is not a " + options.reference + " reference."; } - const schemeHandler = SCHEMES[(options.scheme || parsed.scheme || "").toLowerCase()]; + const schemeHandler = getSchemeHandler(options.scheme || parsed.scheme); if (!options.unicodeSupport && (!schemeHandler || !schemeHandler.unicodeSupport)) { if (parsed.host && (options.domainHost || schemeHandler && schemeHandler.domainHost) && isIP === false && nonSimpleDomain(parsed.host)) { try { @@ -22217,17 +22331,23 @@ var require_fast_uri = __commonJS({ } } if (!schemeHandler || schemeHandler && !schemeHandler.skipNormalize) { - if (gotEncoding && parsed.scheme !== void 0) { - parsed.scheme = unescape(parsed.scheme); - } - if (gotEncoding && parsed.host !== void 0) { - parsed.host = unescape(parsed.host); + if (uri.indexOf("%") !== -1) { + if (parsed.scheme !== void 0) { + parsed.scheme = unescape(parsed.scheme); + } + if (parsed.host !== void 0) { + parsed.host = reescapeHostDelimiters(unescape(parsed.host), isIP); + } } - if (parsed.path !== void 0 && parsed.path.length) { - parsed.path = escape(unescape(parsed.path)); + if (parsed.path) { + parsed.path = normalizePathEncoding(parsed.path); } - if (parsed.fragment !== void 0 && parsed.fragment.length) { - parsed.fragment = encodeURI(decodeURIComponent(parsed.fragment)); + if (parsed.fragment) { + try { + parsed.fragment = encodeURI(decodeURIComponent(parsed.fragment)); + } catch { + parsed.error = parsed.error || "URI malformed"; + } } } if (schemeHandler && schemeHandler.parse) { @@ -22236,13 +22356,35 @@ var require_fast_uri = __commonJS({ } else { parsed.error = parsed.error || "URI can not be parsed."; } - return parsed; + return { parsed, malformedAuthorityOrPort }; + } + function parse2(uri, opts) { + return parseWithStatus(uri, opts).parsed; + } + function normalizeString(uri, opts) { + return normalizeStringWithStatus(uri, opts).normalized; + } + function normalizeStringWithStatus(uri, opts) { + const { parsed, malformedAuthorityOrPort } = parseWithStatus(uri, opts); + return { + normalized: malformedAuthorityOrPort ? uri : serialize(parsed, opts), + malformedAuthorityOrPort + }; + } + function normalizeComparableURI(uri, opts) { + if (typeof uri === "string") { + const { normalized, malformedAuthorityOrPort } = normalizeStringWithStatus(uri, opts); + return malformedAuthorityOrPort ? void 0 : normalized; + } + if (typeof uri === "object") { + return serialize(uri, opts); + } } var fastUri = { SCHEMES, normalize, resolve, - resolveComponents, + resolveComponent, equal, serialize, parse: parse2 diff --git a/dist/update-repo-task-statuses.js b/dist/update-repo-task-statuses.js index 8cc54db6..030113ae 100644 --- a/dist/update-repo-task-statuses.js +++ b/dist/update-repo-task-statuses.js @@ -21586,91 +21586,65 @@ var require_data = __commonJS({ } }); -// node_modules/fast-uri/lib/scopedChars.js -var require_scopedChars = __commonJS({ - "node_modules/fast-uri/lib/scopedChars.js"(exports2, module2) { - "use strict"; - var HEX = { - 0: 0, - 1: 1, - 2: 2, - 3: 3, - 4: 4, - 5: 5, - 6: 6, - 7: 7, - 8: 8, - 9: 9, - a: 10, - A: 10, - b: 11, - B: 11, - c: 12, - C: 12, - d: 13, - D: 13, - e: 14, - E: 14, - f: 15, - F: 15 - }; - module2.exports = { - HEX - }; - } -}); - // node_modules/fast-uri/lib/utils.js var require_utils2 = __commonJS({ "node_modules/fast-uri/lib/utils.js"(exports2, module2) { "use strict"; - var { HEX } = require_scopedChars(); - function normalizeIPv4(host) { - if (findToken(host, ".") < 3) { - return { host, isIPV4: false }; + var isUUID = RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu); + var isIPv4 = RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u); + var isHexPair = RegExp.prototype.test.bind(/^[\da-f]{2}$/iu); + var isUnreserved = RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu); + var isPathCharacter = RegExp.prototype.test.bind(/^[\da-z\-._~!$&'()*+,;=:@/]$/iu); + function stringArrayToHexStripped(input) { + let acc = ""; + let code = 0; + let i = 0; + for (i = 0; i < input.length; i++) { + code = input[i].charCodeAt(0); + if (code === 48) { + continue; + } + if (!(code >= 48 && code <= 57 || code >= 65 && code <= 70 || code >= 97 && code <= 102)) { + return ""; + } + acc += input[i]; + break; } - const matches = host.match(/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/u) || []; - const [address] = matches; - if (address) { - return { host: stripLeadingZeros(address, "."), isIPV4: true }; - } else { - return { host, isIPV4: false }; + for (i += 1; i < input.length; i++) { + code = input[i].charCodeAt(0); + if (!(code >= 48 && code <= 57 || code >= 65 && code <= 70 || code >= 97 && code <= 102)) { + return ""; + } + acc += input[i]; } + return acc; } - function stringArrayToHexStripped(input, keepZero = false) { - let acc = ""; - let strip = true; - for (const c of input) { - if (HEX[c] === void 0) return void 0; - if (c !== "0" && strip === true) strip = false; - if (!strip) acc += c; + var nonSimpleDomain = RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u); + function consumeIsZone(buffer) { + buffer.length = 0; + return true; + } + function consumeHextets(buffer, address, output) { + if (buffer.length) { + const hex = stringArrayToHexStripped(buffer); + if (hex !== "") { + address.push(hex); + } else { + output.error = true; + return false; + } + buffer.length = 0; } - if (keepZero && acc.length === 0) acc = "0"; - return acc; + return true; } function getIPV6(input) { let tokenCount = 0; const output = { error: false, address: "", zone: "" }; const address = []; const buffer = []; - let isZone = false; let endipv6Encountered = false; let endIpv6 = false; - function consume() { - if (buffer.length) { - if (isZone === false) { - const hex = stringArrayToHexStripped(buffer); - if (hex !== void 0) { - address.push(hex); - } else { - output.error = true; - return false; - } - } - buffer.length = 0; - } - return true; - } + let consume = consumeHextets; for (let i = 0; i < input.length; i++) { const cursor = input[i]; if (cursor === "[" || cursor === "]") { @@ -21680,31 +21654,30 @@ var require_utils2 = __commonJS({ if (endipv6Encountered === true) { endIpv6 = true; } - if (!consume()) { + if (!consume(buffer, address, output)) { break; } - tokenCount++; - address.push(":"); - if (tokenCount > 7) { + if (++tokenCount > 7) { output.error = true; break; } - if (i - 1 >= 0 && input[i - 1] === ":") { + if (i > 0 && input[i - 1] === ":") { endipv6Encountered = true; } + address.push(":"); continue; } else if (cursor === "%") { - if (!consume()) { + if (!consume(buffer, address, output)) { break; } - isZone = true; + consume = consumeIsZone; } else { buffer.push(cursor); continue; } } if (buffer.length) { - if (isZone) { + if (consume === consumeIsZone) { output.zone = buffer.join(""); } else if (endIpv6) { address.push(buffer.join("")); @@ -21715,7 +21688,7 @@ var require_utils2 = __commonJS({ output.address = address.join(""); return output; } - function normalizeIPv6(host, opts = {}) { + function normalizeIPv6(host) { if (findToken(host, ":") < 2) { return { host, isIPV6: false }; } @@ -21727,33 +21700,11 @@ var require_utils2 = __commonJS({ newHost += "%" + ipv6.zone; escapedHost += "%25" + ipv6.zone; } - return { host: newHost, escapedHost, isIPV6: true }; + return { host: newHost, isIPV6: true, escapedHost }; } else { return { host, isIPV6: false }; } } - function stripLeadingZeros(str, token) { - let out = ""; - let skip = true; - const l = str.length; - for (let i = 0; i < l; i++) { - const c = str[i]; - if (c === "0" && skip) { - if (i + 1 <= l && str[i + 1] === token || i + 1 === l) { - out += c; - skip = false; - } - } else { - if (c === token) { - skip = true; - } else { - skip = false; - } - out += c; - } - } - return out; - } function findToken(str, token) { let ind = 0; for (let i = 0; i < str.length; i++) { @@ -21761,89 +21712,187 @@ var require_utils2 = __commonJS({ } return ind; } - var RDS1 = /^\.\.?\//u; - var RDS2 = /^\/\.(?:\/|$)/u; - var RDS3 = /^\/\.\.(?:\/|$)/u; - var RDS5 = /^\/?(?:.|\n)*?(?=\/|$)/u; - function removeDotSegments(input) { + function removeDotSegments(path) { + let input = path; const output = []; - while (input.length) { - if (input.match(RDS1)) { - input = input.replace(RDS1, ""); - } else if (input.match(RDS2)) { - input = input.replace(RDS2, "/"); - } else if (input.match(RDS3)) { - input = input.replace(RDS3, "/"); - output.pop(); - } else if (input === "." || input === "..") { - input = ""; - } else { - const im = input.match(RDS5); - if (im) { - const s = im[0]; - input = input.slice(s.length); - output.push(s); + let nextSlash = -1; + let len = 0; + while (len = input.length) { + if (len === 1) { + if (input === ".") { + break; + } else if (input === "/") { + output.push("/"); + break; } else { - throw new Error("Unexpected dot segment condition"); + output.push(input); + break; + } + } else if (len === 2) { + if (input[0] === ".") { + if (input[1] === ".") { + break; + } else if (input[1] === "/") { + input = input.slice(2); + continue; + } + } else if (input[0] === "/") { + if (input[1] === "." || input[1] === "/") { + output.push("/"); + break; + } + } + } else if (len === 3) { + if (input === "/..") { + if (output.length !== 0) { + output.pop(); + } + output.push("/"); + break; } } + if (input[0] === ".") { + if (input[1] === ".") { + if (input[2] === "/") { + input = input.slice(3); + continue; + } + } else if (input[1] === "/") { + input = input.slice(2); + continue; + } + } else if (input[0] === "/") { + if (input[1] === ".") { + if (input[2] === "/") { + input = input.slice(2); + continue; + } else if (input[2] === ".") { + if (input[3] === "/") { + input = input.slice(3); + if (output.length !== 0) { + output.pop(); + } + continue; + } + } + } + } + if ((nextSlash = input.indexOf("/", 1)) === -1) { + output.push(input); + break; + } else { + output.push(input.slice(0, nextSlash)); + input = input.slice(nextSlash); + } } return output.join(""); } - function normalizeComponentEncoding(components, esc) { - const func = esc !== true ? escape : unescape; - if (components.scheme !== void 0) { - components.scheme = func(components.scheme); - } - if (components.userinfo !== void 0) { - components.userinfo = func(components.userinfo); - } - if (components.host !== void 0) { - components.host = func(components.host); + var HOST_DELIMS = { "@": "%40", "/": "%2F", "?": "%3F", "#": "%23", ":": "%3A" }; + var HOST_DELIM_RE = /[@/?#:]/g; + var HOST_DELIM_NO_COLON_RE = /[@/?#]/g; + function reescapeHostDelimiters(host, isIP) { + const re = isIP ? HOST_DELIM_NO_COLON_RE : HOST_DELIM_RE; + re.lastIndex = 0; + return host.replace(re, (ch) => HOST_DELIMS[ch]); + } + function normalizePercentEncoding(input, decodeUnreserved = false) { + if (input.indexOf("%") === -1) { + return input; } - if (components.path !== void 0) { - components.path = func(components.path); + let output = ""; + for (let i = 0; i < input.length; i++) { + if (input[i] === "%" && i + 2 < input.length) { + const hex = input.slice(i + 1, i + 3); + if (isHexPair(hex)) { + const normalizedHex = hex.toUpperCase(); + const decoded = String.fromCharCode(parseInt(normalizedHex, 16)); + if (decodeUnreserved && isUnreserved(decoded)) { + output += decoded; + } else { + output += "%" + normalizedHex; + } + i += 2; + continue; + } + } + output += input[i]; } - if (components.query !== void 0) { - components.query = func(components.query); + return output; + } + function normalizePathEncoding(input) { + let output = ""; + for (let i = 0; i < input.length; i++) { + if (input[i] === "%" && i + 2 < input.length) { + const hex = input.slice(i + 1, i + 3); + if (isHexPair(hex)) { + const normalizedHex = hex.toUpperCase(); + const decoded = String.fromCharCode(parseInt(normalizedHex, 16)); + if (decoded !== "." && isUnreserved(decoded)) { + output += decoded; + } else { + output += "%" + normalizedHex; + } + i += 2; + continue; + } + } + if (isPathCharacter(input[i])) { + output += input[i]; + } else { + output += escape(input[i]); + } } - if (components.fragment !== void 0) { - components.fragment = func(components.fragment); + return output; + } + function escapePreservingEscapes(input) { + let output = ""; + for (let i = 0; i < input.length; i++) { + if (input[i] === "%" && i + 2 < input.length) { + const hex = input.slice(i + 1, i + 3); + if (isHexPair(hex)) { + output += "%" + hex.toUpperCase(); + i += 2; + continue; + } + } + output += escape(input[i]); } - return components; + return output; } - function recomposeAuthority(components, options) { + function recomposeAuthority(component) { const uriTokens = []; - if (components.userinfo !== void 0) { - uriTokens.push(components.userinfo); + if (component.userinfo !== void 0) { + uriTokens.push(component.userinfo); uriTokens.push("@"); } - if (components.host !== void 0) { - let host = unescape(components.host); - const ipV4res = normalizeIPv4(host); - if (ipV4res.isIPV4) { - host = ipV4res.host; - } else { - const ipV6res = normalizeIPv6(ipV4res.host, { isIPV4: false }); + if (component.host !== void 0) { + let host = unescape(component.host); + if (!isIPv4(host)) { + const ipV6res = normalizeIPv6(host); if (ipV6res.isIPV6 === true) { host = `[${ipV6res.escapedHost}]`; } else { - host = components.host; + host = reescapeHostDelimiters(host, false); } } uriTokens.push(host); } - if (typeof components.port === "number" || typeof components.port === "string") { + if (typeof component.port === "number" || typeof component.port === "string") { uriTokens.push(":"); - uriTokens.push(String(components.port)); + uriTokens.push(String(component.port)); } return uriTokens.length ? uriTokens.join("") : void 0; } module2.exports = { + nonSimpleDomain, recomposeAuthority, - normalizeComponentEncoding, + reescapeHostDelimiters, + normalizePercentEncoding, + normalizePathEncoding, + escapePreservingEscapes, removeDotSegments, - normalizeIPv4, + isIPv4, + isUUID, normalizeIPv6, stringArrayToHexStripped }; @@ -21854,145 +21903,209 @@ var require_utils2 = __commonJS({ var require_schemes = __commonJS({ "node_modules/fast-uri/lib/schemes.js"(exports2, module2) { "use strict"; - var UUID_REG = /^[\da-f]{8}\b-[\da-f]{4}\b-[\da-f]{4}\b-[\da-f]{4}\b-[\da-f]{12}$/iu; + var { isUUID } = require_utils2(); var URN_REG = /([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu; - function isSecure(wsComponents) { - return typeof wsComponents.secure === "boolean" ? wsComponents.secure : String(wsComponents.scheme).toLowerCase() === "wss"; + var supportedSchemeNames = ( + /** @type {const} */ + [ + "http", + "https", + "ws", + "wss", + "urn", + "urn:uuid" + ] + ); + function isValidSchemeName(name) { + return supportedSchemeNames.indexOf( + /** @type {*} */ + name + ) !== -1; + } + function wsIsSecure(wsComponent) { + if (wsComponent.secure === true) { + return true; + } else if (wsComponent.secure === false) { + return false; + } else if (wsComponent.scheme) { + return wsComponent.scheme.length === 3 && (wsComponent.scheme[0] === "w" || wsComponent.scheme[0] === "W") && (wsComponent.scheme[1] === "s" || wsComponent.scheme[1] === "S") && (wsComponent.scheme[2] === "s" || wsComponent.scheme[2] === "S"); + } else { + return false; + } } - function httpParse(components) { - if (!components.host) { - components.error = components.error || "HTTP URIs must have a host."; + function httpParse(component) { + if (!component.host) { + component.error = component.error || "HTTP URIs must have a host."; } - return components; + return component; } - function httpSerialize(components) { - const secure = String(components.scheme).toLowerCase() === "https"; - if (components.port === (secure ? 443 : 80) || components.port === "") { - components.port = void 0; + function httpSerialize(component) { + const secure = String(component.scheme).toLowerCase() === "https"; + if (component.port === (secure ? 443 : 80) || component.port === "") { + component.port = void 0; } - if (!components.path) { - components.path = "/"; + if (!component.path) { + component.path = "/"; } - return components; + return component; } - function wsParse(wsComponents) { - wsComponents.secure = isSecure(wsComponents); - wsComponents.resourceName = (wsComponents.path || "/") + (wsComponents.query ? "?" + wsComponents.query : ""); - wsComponents.path = void 0; - wsComponents.query = void 0; - return wsComponents; + function wsParse(wsComponent) { + wsComponent.secure = wsIsSecure(wsComponent); + wsComponent.resourceName = (wsComponent.path || "/") + (wsComponent.query ? "?" + wsComponent.query : ""); + wsComponent.path = void 0; + wsComponent.query = void 0; + return wsComponent; } - function wsSerialize(wsComponents) { - if (wsComponents.port === (isSecure(wsComponents) ? 443 : 80) || wsComponents.port === "") { - wsComponents.port = void 0; + function wsSerialize(wsComponent) { + if (wsComponent.port === (wsIsSecure(wsComponent) ? 443 : 80) || wsComponent.port === "") { + wsComponent.port = void 0; } - if (typeof wsComponents.secure === "boolean") { - wsComponents.scheme = wsComponents.secure ? "wss" : "ws"; - wsComponents.secure = void 0; + if (typeof wsComponent.secure === "boolean") { + wsComponent.scheme = wsComponent.secure ? "wss" : "ws"; + wsComponent.secure = void 0; } - if (wsComponents.resourceName) { - const [path, query] = wsComponents.resourceName.split("?"); - wsComponents.path = path && path !== "/" ? path : void 0; - wsComponents.query = query; - wsComponents.resourceName = void 0; + if (wsComponent.resourceName) { + const [path, query] = wsComponent.resourceName.split("?"); + wsComponent.path = path && path !== "/" ? path : void 0; + wsComponent.query = query; + wsComponent.resourceName = void 0; } - wsComponents.fragment = void 0; - return wsComponents; + wsComponent.fragment = void 0; + return wsComponent; } - function urnParse(urnComponents, options) { - if (!urnComponents.path) { - urnComponents.error = "URN can not be parsed"; - return urnComponents; + function urnParse(urnComponent, options) { + if (!urnComponent.path) { + urnComponent.error = "URN can not be parsed"; + return urnComponent; } - const matches = urnComponents.path.match(URN_REG); + const matches = urnComponent.path.match(URN_REG); if (matches) { - const scheme = options.scheme || urnComponents.scheme || "urn"; - urnComponents.nid = matches[1].toLowerCase(); - urnComponents.nss = matches[2]; - const urnScheme = `${scheme}:${options.nid || urnComponents.nid}`; - const schemeHandler = SCHEMES[urnScheme]; - urnComponents.path = void 0; + const scheme = options.scheme || urnComponent.scheme || "urn"; + urnComponent.nid = matches[1].toLowerCase(); + urnComponent.nss = matches[2]; + const urnScheme = `${scheme}:${options.nid || urnComponent.nid}`; + const schemeHandler = getSchemeHandler(urnScheme); + urnComponent.path = void 0; if (schemeHandler) { - urnComponents = schemeHandler.parse(urnComponents, options); + urnComponent = schemeHandler.parse(urnComponent, options); } } else { - urnComponents.error = urnComponents.error || "URN can not be parsed."; + urnComponent.error = urnComponent.error || "URN can not be parsed."; } - return urnComponents; + return urnComponent; } - function urnSerialize(urnComponents, options) { - const scheme = options.scheme || urnComponents.scheme || "urn"; - const nid = urnComponents.nid.toLowerCase(); + function urnSerialize(urnComponent, options) { + if (urnComponent.nid === void 0) { + throw new Error("URN without nid cannot be serialized"); + } + const scheme = options.scheme || urnComponent.scheme || "urn"; + const nid = urnComponent.nid.toLowerCase(); const urnScheme = `${scheme}:${options.nid || nid}`; - const schemeHandler = SCHEMES[urnScheme]; + const schemeHandler = getSchemeHandler(urnScheme); if (schemeHandler) { - urnComponents = schemeHandler.serialize(urnComponents, options); + urnComponent = schemeHandler.serialize(urnComponent, options); } - const uriComponents = urnComponents; - const nss = urnComponents.nss; - uriComponents.path = `${nid || options.nid}:${nss}`; + const uriComponent = urnComponent; + const nss = urnComponent.nss; + uriComponent.path = `${nid || options.nid}:${nss}`; options.skipEscape = true; - return uriComponents; - } - function urnuuidParse(urnComponents, options) { - const uuidComponents = urnComponents; - uuidComponents.uuid = uuidComponents.nss; - uuidComponents.nss = void 0; - if (!options.tolerant && (!uuidComponents.uuid || !UUID_REG.test(uuidComponents.uuid))) { - uuidComponents.error = uuidComponents.error || "UUID is not valid."; - } - return uuidComponents; - } - function urnuuidSerialize(uuidComponents) { - const urnComponents = uuidComponents; - urnComponents.nss = (uuidComponents.uuid || "").toLowerCase(); - return urnComponents; - } - var http = { - scheme: "http", - domainHost: true, - parse: httpParse, - serialize: httpSerialize - }; - var https = { - scheme: "https", - domainHost: http.domainHost, - parse: httpParse, - serialize: httpSerialize - }; - var ws = { - scheme: "ws", - domainHost: true, - parse: wsParse, - serialize: wsSerialize - }; - var wss = { - scheme: "wss", - domainHost: ws.domainHost, - parse: ws.parse, - serialize: ws.serialize - }; - var urn = { - scheme: "urn", - parse: urnParse, - serialize: urnSerialize, - skipNormalize: true - }; - var urnuuid = { - scheme: "urn:uuid", - parse: urnuuidParse, - serialize: urnuuidSerialize, - skipNormalize: true - }; - var SCHEMES = { - http, - https, - ws, - wss, - urn, - "urn:uuid": urnuuid - }; - module2.exports = SCHEMES; + return uriComponent; + } + function urnuuidParse(urnComponent, options) { + const uuidComponent = urnComponent; + uuidComponent.uuid = uuidComponent.nss; + uuidComponent.nss = void 0; + if (!options.tolerant && (!uuidComponent.uuid || !isUUID(uuidComponent.uuid))) { + uuidComponent.error = uuidComponent.error || "UUID is not valid."; + } + return uuidComponent; + } + function urnuuidSerialize(uuidComponent) { + const urnComponent = uuidComponent; + urnComponent.nss = (uuidComponent.uuid || "").toLowerCase(); + return urnComponent; + } + var http = ( + /** @type {SchemeHandler} */ + { + scheme: "http", + domainHost: true, + parse: httpParse, + serialize: httpSerialize + } + ); + var https = ( + /** @type {SchemeHandler} */ + { + scheme: "https", + domainHost: http.domainHost, + parse: httpParse, + serialize: httpSerialize + } + ); + var ws = ( + /** @type {SchemeHandler} */ + { + scheme: "ws", + domainHost: true, + parse: wsParse, + serialize: wsSerialize + } + ); + var wss = ( + /** @type {SchemeHandler} */ + { + scheme: "wss", + domainHost: ws.domainHost, + parse: ws.parse, + serialize: ws.serialize + } + ); + var urn = ( + /** @type {SchemeHandler} */ + { + scheme: "urn", + parse: urnParse, + serialize: urnSerialize, + skipNormalize: true + } + ); + var urnuuid = ( + /** @type {SchemeHandler} */ + { + scheme: "urn:uuid", + parse: urnuuidParse, + serialize: urnuuidSerialize, + skipNormalize: true + } + ); + var SCHEMES = ( + /** @type {Record} */ + { + http, + https, + ws, + wss, + urn, + "urn:uuid": urnuuid + } + ); + Object.setPrototypeOf(SCHEMES, null); + function getSchemeHandler(scheme) { + return scheme && (SCHEMES[ + /** @type {SchemeName} */ + scheme + ] || SCHEMES[ + /** @type {SchemeName} */ + scheme.toLowerCase() + ]) || void 0; + } + module2.exports = { + wsIsSecure, + SCHEMES, + isValidSchemeName, + getSchemeHandler + }; } }); @@ -22000,22 +22113,25 @@ var require_schemes = __commonJS({ var require_fast_uri = __commonJS({ "node_modules/fast-uri/index.js"(exports2, module2) { "use strict"; - var { normalizeIPv6, normalizeIPv4, removeDotSegments, recomposeAuthority, normalizeComponentEncoding } = require_utils2(); - var SCHEMES = require_schemes(); + var { normalizeIPv6, removeDotSegments, recomposeAuthority, normalizePercentEncoding, normalizePathEncoding, escapePreservingEscapes, reescapeHostDelimiters, isIPv4, nonSimpleDomain } = require_utils2(); + var { SCHEMES, getSchemeHandler } = require_schemes(); function normalize(uri, options) { if (typeof uri === "string") { - uri = serialize(parse2(uri, options), options); + uri = /** @type {T} */ + normalizeString(uri, options); } else if (typeof uri === "object") { - uri = parse2(serialize(uri, options), options); + uri = /** @type {T} */ + parse2(serialize(uri, options), options); } return uri; } function resolve(baseURI, relativeURI, options) { - const schemelessOptions = Object.assign({ scheme: "null" }, options); - const resolved = resolveComponents(parse2(baseURI, schemelessOptions), parse2(relativeURI, schemelessOptions), schemelessOptions, true); - return serialize(resolved, { ...schemelessOptions, skipEscape: true }); + const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" }; + const resolved = resolveComponent(parse2(baseURI, schemelessOptions), parse2(relativeURI, schemelessOptions), schemelessOptions, true); + schemelessOptions.skipEscape = true; + return serialize(resolved, schemelessOptions); } - function resolveComponents(base, relative, options, skipNormalization) { + function resolveComponent(base, relative, options, skipNormalization) { const target = {}; if (!skipNormalization) { base = parse2(serialize(base, options), options); @@ -22045,7 +22161,7 @@ var require_fast_uri = __commonJS({ target.query = base.query; } } else { - if (relative.path.charAt(0) === "/") { + if (relative.path[0] === "/") { target.path = removeDotSegments(relative.path); } else { if ((base.userinfo !== void 0 || base.host !== void 0 || base.port !== void 0) && !base.path) { @@ -22069,22 +22185,12 @@ var require_fast_uri = __commonJS({ return target; } function equal(uriA, uriB, options) { - if (typeof uriA === "string") { - uriA = unescape(uriA); - uriA = serialize(normalizeComponentEncoding(parse2(uriA, options), true), { ...options, skipEscape: true }); - } else if (typeof uriA === "object") { - uriA = serialize(normalizeComponentEncoding(uriA, true), { ...options, skipEscape: true }); - } - if (typeof uriB === "string") { - uriB = unescape(uriB); - uriB = serialize(normalizeComponentEncoding(parse2(uriB, options), true), { ...options, skipEscape: true }); - } else if (typeof uriB === "object") { - uriB = serialize(normalizeComponentEncoding(uriB, true), { ...options, skipEscape: true }); - } - return uriA.toLowerCase() === uriB.toLowerCase(); + const normalizedA = normalizeComparableURI(uriA, options); + const normalizedB = normalizeComparableURI(uriB, options); + return normalizedA !== void 0 && normalizedB !== void 0 && normalizedA.toLowerCase() === normalizedB.toLowerCase(); } function serialize(cmpts, opts) { - const components = { + const component = { host: cmpts.host, scheme: cmpts.scheme, userinfo: cmpts.userinfo, @@ -22102,62 +22208,60 @@ var require_fast_uri = __commonJS({ }; const options = Object.assign({}, opts); const uriTokens = []; - const schemeHandler = SCHEMES[(options.scheme || components.scheme || "").toLowerCase()]; - if (schemeHandler && schemeHandler.serialize) schemeHandler.serialize(components, options); - if (components.path !== void 0) { + const schemeHandler = getSchemeHandler(options.scheme || component.scheme); + if (schemeHandler && schemeHandler.serialize) schemeHandler.serialize(component, options); + if (component.path !== void 0) { if (!options.skipEscape) { - components.path = escape(components.path); - if (components.scheme !== void 0) { - components.path = components.path.split("%3A").join(":"); + component.path = escapePreservingEscapes(component.path); + if (component.scheme !== void 0) { + component.path = component.path.split("%3A").join(":"); } } else { - components.path = unescape(components.path); + component.path = normalizePercentEncoding(component.path); } } - if (options.reference !== "suffix" && components.scheme) { - uriTokens.push(components.scheme, ":"); + if (options.reference !== "suffix" && component.scheme) { + uriTokens.push(component.scheme, ":"); } - const authority = recomposeAuthority(components, options); + const authority = recomposeAuthority(component); if (authority !== void 0) { if (options.reference !== "suffix") { uriTokens.push("//"); } uriTokens.push(authority); - if (components.path && components.path.charAt(0) !== "/") { + if (component.path && component.path[0] !== "/") { uriTokens.push("/"); } } - if (components.path !== void 0) { - let s = components.path; + if (component.path !== void 0) { + let s = component.path; if (!options.absolutePath && (!schemeHandler || !schemeHandler.absolutePath)) { s = removeDotSegments(s); } - if (authority === void 0) { - s = s.replace(/^\/\//u, "/%2F"); + if (authority === void 0 && s[0] === "/" && s[1] === "/") { + s = "/%2F" + s.slice(2); } uriTokens.push(s); } - if (components.query !== void 0) { - uriTokens.push("?", components.query); + if (component.query !== void 0) { + uriTokens.push("?", component.query); } - if (components.fragment !== void 0) { - uriTokens.push("#", components.fragment); + if (component.fragment !== void 0) { + uriTokens.push("#", component.fragment); } return uriTokens.join(""); } - var hexLookUp = Array.from({ length: 127 }, (v, k) => /[^!"$&'()*+,\-.;=_`a-z{}~]/u.test(String.fromCharCode(k))); - function nonSimpleDomain(value) { - let code = 0; - for (let i = 0, len = value.length; i < len; ++i) { - code = value.charCodeAt(i); - if (code > 126 || hexLookUp[code]) { - return true; - } + var URI_PARSE = /^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u; + function getParseError(parsed, matches) { + if (matches[2] !== void 0 && parsed.path && parsed.path[0] !== "/") { + return 'URI path must start with "/" when authority is present.'; } - return false; + if (typeof parsed.port === "number" && (parsed.port < 0 || parsed.port > 65535)) { + return "URI port is malformed."; + } + return void 0; } - var URI_PARSE = /^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u; - function parse2(uri, opts) { + function parseWithStatus(uri, opts) { const options = Object.assign({}, opts); const parsed = { scheme: void 0, @@ -22168,9 +22272,15 @@ var require_fast_uri = __commonJS({ query: void 0, fragment: void 0 }; - const gotEncoding = uri.indexOf("%") !== -1; + let malformedAuthorityOrPort = false; let isIP = false; - if (options.reference === "suffix") uri = (options.scheme ? options.scheme + ":" : "") + "//" + uri; + if (options.reference === "suffix") { + if (options.scheme) { + uri = options.scheme + ":" + uri; + } else { + uri = "//" + uri; + } + } const matches = uri.match(URI_PARSE); if (matches) { parsed.scheme = matches[1]; @@ -22183,18 +22293,22 @@ var require_fast_uri = __commonJS({ if (isNaN(parsed.port)) { parsed.port = matches[5]; } + const parseError = getParseError(parsed, matches); + if (parseError !== void 0) { + parsed.error = parsed.error || parseError; + malformedAuthorityOrPort = true; + } if (parsed.host) { - const ipv4result = normalizeIPv4(parsed.host); - if (ipv4result.isIPV4 === false) { - const ipv6result = normalizeIPv6(ipv4result.host, { isIPV4: false }); + const ipv4result = isIPv4(parsed.host); + if (ipv4result === false) { + const ipv6result = normalizeIPv6(parsed.host); parsed.host = ipv6result.host.toLowerCase(); isIP = ipv6result.isIPV6; } else { - parsed.host = ipv4result.host; isIP = true; } } - if (parsed.scheme === void 0 && parsed.userinfo === void 0 && parsed.host === void 0 && parsed.port === void 0 && !parsed.path && parsed.query === void 0) { + if (parsed.scheme === void 0 && parsed.userinfo === void 0 && parsed.host === void 0 && parsed.port === void 0 && parsed.query === void 0 && !parsed.path) { parsed.reference = "same-document"; } else if (parsed.scheme === void 0) { parsed.reference = "relative"; @@ -22206,7 +22320,7 @@ var require_fast_uri = __commonJS({ if (options.reference && options.reference !== "suffix" && options.reference !== parsed.reference) { parsed.error = parsed.error || "URI is not a " + options.reference + " reference."; } - const schemeHandler = SCHEMES[(options.scheme || parsed.scheme || "").toLowerCase()]; + const schemeHandler = getSchemeHandler(options.scheme || parsed.scheme); if (!options.unicodeSupport && (!schemeHandler || !schemeHandler.unicodeSupport)) { if (parsed.host && (options.domainHost || schemeHandler && schemeHandler.domainHost) && isIP === false && nonSimpleDomain(parsed.host)) { try { @@ -22217,17 +22331,23 @@ var require_fast_uri = __commonJS({ } } if (!schemeHandler || schemeHandler && !schemeHandler.skipNormalize) { - if (gotEncoding && parsed.scheme !== void 0) { - parsed.scheme = unescape(parsed.scheme); - } - if (gotEncoding && parsed.host !== void 0) { - parsed.host = unescape(parsed.host); + if (uri.indexOf("%") !== -1) { + if (parsed.scheme !== void 0) { + parsed.scheme = unescape(parsed.scheme); + } + if (parsed.host !== void 0) { + parsed.host = reescapeHostDelimiters(unescape(parsed.host), isIP); + } } - if (parsed.path !== void 0 && parsed.path.length) { - parsed.path = escape(unescape(parsed.path)); + if (parsed.path) { + parsed.path = normalizePathEncoding(parsed.path); } - if (parsed.fragment !== void 0 && parsed.fragment.length) { - parsed.fragment = encodeURI(decodeURIComponent(parsed.fragment)); + if (parsed.fragment) { + try { + parsed.fragment = encodeURI(decodeURIComponent(parsed.fragment)); + } catch { + parsed.error = parsed.error || "URI malformed"; + } } } if (schemeHandler && schemeHandler.parse) { @@ -22236,13 +22356,35 @@ var require_fast_uri = __commonJS({ } else { parsed.error = parsed.error || "URI can not be parsed."; } - return parsed; + return { parsed, malformedAuthorityOrPort }; + } + function parse2(uri, opts) { + return parseWithStatus(uri, opts).parsed; + } + function normalizeString(uri, opts) { + return normalizeStringWithStatus(uri, opts).normalized; + } + function normalizeStringWithStatus(uri, opts) { + const { parsed, malformedAuthorityOrPort } = parseWithStatus(uri, opts); + return { + normalized: malformedAuthorityOrPort ? uri : serialize(parsed, opts), + malformedAuthorityOrPort + }; + } + function normalizeComparableURI(uri, opts) { + if (typeof uri === "string") { + const { normalized, malformedAuthorityOrPort } = normalizeStringWithStatus(uri, opts); + return malformedAuthorityOrPort ? void 0 : normalized; + } + if (typeof uri === "object") { + return serialize(uri, opts); + } } var fastUri = { SCHEMES, normalize, resolve, - resolveComponents, + resolveComponent, equal, serialize, parse: parse2 diff --git a/package-lock.json b/package-lock.json index 0f9d045e..86545879 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6624,9 +6624,20 @@ "license": "MIT" }, "node_modules/fast-uri": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-3.0.2.tgz", - "integrity": "sha512-GR6f0hD7XXyNJa25Tb9BuIdN0tdr+0BMi6/CJPH3wJO1JjNG3n/VsSw38AwRdKZABm8lGbPfakLRkYzx2V9row==" + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-3.1.2.tgz", + "integrity": "sha512-rVjf7ArG3LTk+FS6Yw81V1DLuZl1bRbNrev6Tmd/9RaroeeRRJhAt7jg/6YFxbvAQXUCavSoZhPPj6oOx+5KjQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/fastify" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/fastify" + } + ], + "license": "BSD-3-Clause" }, "node_modules/fastq": { "version": "1.11.1",