aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2023-07-06 16:49:41 -0700
committerGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2023-07-06 16:49:41 -0700
commit038ca83004d43b7943ba141756e51df6b8c279fd (patch)
tree555eb0910e7dc4beb5680ec1f4514feb76853cb1
parentd377265b67df34495274ad7be9f8ad1852e3b23b (diff)
downloadbun-038ca83004d43b7943ba141756e51df6b8c279fd.tar.gz
bun-038ca83004d43b7943ba141756e51df6b8c279fd.tar.zst
bun-038ca83004d43b7943ba141756e51df6b8c279fd.zip
Add missing export in `url`
-rw-r--r--src/js/build-esm.ts1
-rw-r--r--src/js/node/url.js1
-rw-r--r--src/js/out/modules/node/url.js367
3 files changed, 3 insertions, 366 deletions
diff --git a/src/js/build-esm.ts b/src/js/build-esm.ts
index b3ece01a1..f3d9feed7 100644
--- a/src/js/build-esm.ts
+++ b/src/js/build-esm.ts
@@ -20,6 +20,7 @@ const minifyList = [
"node/stream.promises.js",
"node/stream.consumers.js",
"node/stream.web.js",
+ "node/url.js",
];
if (fs.existsSync(OUT_DIR + "/modules")) {
diff --git a/src/js/node/url.js b/src/js/node/url.js
index 9fb1b4374..bb7093bcc 100644
--- a/src/js/node/url.js
+++ b/src/js/node/url.js
@@ -834,6 +834,7 @@ const defaultObject = {
pathToFileURL,
fileURLToPath,
urlToHttpOptions,
+ [Symbol.for("CommonJS")]: 0,
};
export {
diff --git a/src/js/out/modules/node/url.js b/src/js/out/modules/node/url.js
index 25172c68f..adff460cf 100644
--- a/src/js/out/modules/node/url.js
+++ b/src/js/out/modules/node/url.js
@@ -1,366 +1 @@
-var Url = function() {
- this.protocol = null, this.slashes = null, this.auth = null, this.host = null, this.port = null, this.hostname = null, this.hash = null, this.search = null, this.query = null, this.pathname = null, this.path = null, this.href = null;
-}, urlParse = function(url, parseQueryString, slashesDenoteHost) {
- if (url && typeof url === "object" && url instanceof Url)
- return url;
- var u = new Url;
- return u.parse(url, parseQueryString, slashesDenoteHost), u;
-}, urlFormat = function(obj) {
- if (typeof obj === "string")
- obj = urlParse(obj);
- if (!(obj instanceof Url))
- return Url.prototype.format.call(obj);
- return obj.format();
-}, urlResolve = function(source, relative) {
- return urlParse(source, !1, !0).resolve(relative);
-}, urlResolveObject = function(source, relative) {
- if (!source)
- return relative;
- return urlParse(source, !1, !0).resolveObject(relative);
-}, urlToHttpOptions = function(url) {
- const options = {
- protocol: url.protocol,
- hostname: typeof url.hostname === "string" && url.hostname.startsWith("[") ? url.hostname.slice(1, -1) : url.hostname,
- hash: url.hash,
- search: url.search,
- pathname: url.pathname,
- path: `${url.pathname || ""}${url.search || ""}`,
- href: url.href
- };
- if (url.port !== "")
- options.port = Number(url.port);
- if (url.username || url.password)
- options.auth = `${decodeURIComponent(url.username)}:${decodeURIComponent(url.password)}`;
- return options;
-}, { URL, URLSearchParams } = globalThis, protocolPattern = /^([a-z0-9.+-]+:)/i, portPattern = /:[0-9]*$/, simplePathPattern = /^(\/\/?(?!\/)[^?\s]*)(\?[^\s]*)?$/, delims = ["<", ">", '"', "`", " ", "\r", "\n", "\t"], unwise = ["{", "}", "|", "\\", "^", "`"].concat(delims), autoEscape = ["'"].concat(unwise), nonHostChars = ["%", "/", "?", ";", "#"].concat(autoEscape), hostEndingChars = ["/", "?", "#"], hostnameMaxLen = 255, hostnamePartPattern = /^[+a-z0-9A-Z_-]{0,63}$/, hostnamePartStart = /^([+a-z0-9A-Z_-]{0,63})(.*)$/, unsafeProtocol = {
- javascript: !0,
- "javascript:": !0
-}, hostlessProtocol = {
- javascript: !0,
- "javascript:": !0
-}, slashedProtocol = {
- http: !0,
- https: !0,
- ftp: !0,
- gopher: !0,
- file: !0,
- "http:": !0,
- "https:": !0,
- "ftp:": !0,
- "gopher:": !0,
- "file:": !0
-};
-Url.prototype.parse = function(url, parseQueryString, slashesDenoteHost) {
- if (typeof url !== "string")
- throw new TypeError("Parameter 'url' must be a string, not " + typeof url);
- var queryIndex = url.indexOf("?"), splitter = queryIndex !== -1 && queryIndex < url.indexOf("#") ? "?" : "#", uSplit = url.split(splitter), slashRegex = /\\/g;
- uSplit[0] = uSplit[0].replace(slashRegex, "/"), url = uSplit.join(splitter);
- var rest = url;
- if (rest = rest.trim(), !slashesDenoteHost && url.split("#").length === 1) {
- var simplePath = simplePathPattern.exec(rest);
- if (simplePath) {
- if (this.path = rest, this.href = rest, this.pathname = simplePath[1], simplePath[2])
- if (this.search = simplePath[2], parseQueryString)
- this.query = new URLSearchParams(this.search.substr(1)).toJSON();
- else
- this.query = this.search.substr(1);
- else if (parseQueryString)
- this.search = "", this.query = {};
- return this;
- }
- }
- var proto = protocolPattern.exec(rest);
- if (proto) {
- proto = proto[0];
- var lowerProto = proto.toLowerCase();
- this.protocol = lowerProto, rest = rest.substr(proto.length);
- }
- if (slashesDenoteHost || proto || rest.match(/^\/\/[^@/]+@[^@/]+/)) {
- var slashes = rest.substr(0, 2) === "//";
- if (slashes && !(proto && hostlessProtocol[proto]))
- rest = rest.substr(2), this.slashes = !0;
- }
- if (!hostlessProtocol[proto] && (slashes || proto && !slashedProtocol[proto])) {
- var hostEnd = -1;
- for (var i = 0;i < hostEndingChars.length; i++) {
- var hec = rest.indexOf(hostEndingChars[i]);
- if (hec !== -1 && (hostEnd === -1 || hec < hostEnd))
- hostEnd = hec;
- }
- var auth, atSign;
- if (hostEnd === -1)
- atSign = rest.lastIndexOf("@");
- else
- atSign = rest.lastIndexOf("@", hostEnd);
- if (atSign !== -1)
- auth = rest.slice(0, atSign), rest = rest.slice(atSign + 1), this.auth = decodeURIComponent(auth);
- hostEnd = -1;
- for (var i = 0;i < nonHostChars.length; i++) {
- var hec = rest.indexOf(nonHostChars[i]);
- if (hec !== -1 && (hostEnd === -1 || hec < hostEnd))
- hostEnd = hec;
- }
- if (hostEnd === -1)
- hostEnd = rest.length;
- this.host = rest.slice(0, hostEnd), rest = rest.slice(hostEnd), this.parseHost(), this.hostname = this.hostname || "";
- var ipv6Hostname = this.hostname[0] === "[" && this.hostname[this.hostname.length - 1] === "]";
- if (!ipv6Hostname) {
- var hostparts = this.hostname.split(/\./);
- for (var i = 0, l = hostparts.length;i < l; i++) {
- var part = hostparts[i];
- if (!part)
- continue;
- if (!part.match(hostnamePartPattern)) {
- var newpart = "";
- for (var j = 0, k = part.length;j < k; j++)
- if (part.charCodeAt(j) > 127)
- newpart += "x";
- else
- newpart += part[j];
- if (!newpart.match(hostnamePartPattern)) {
- var validParts = hostparts.slice(0, i), notHost = hostparts.slice(i + 1), bit = part.match(hostnamePartStart);
- if (bit)
- validParts.push(bit[1]), notHost.unshift(bit[2]);
- if (notHost.length)
- rest = "/" + notHost.join(".") + rest;
- this.hostname = validParts.join(".");
- break;
- }
- }
- }
- }
- if (this.hostname.length > hostnameMaxLen)
- this.hostname = "";
- else
- this.hostname = this.hostname.toLowerCase();
- if (!ipv6Hostname)
- this.hostname = new URL("http://" + this.hostname).hostname;
- var p = this.port ? ":" + this.port : "", h = this.hostname || "";
- if (this.host = h + p, this.href += this.host, ipv6Hostname) {
- if (this.hostname = this.hostname.substr(1, this.hostname.length - 2), rest[0] !== "/")
- rest = "/" + rest;
- }
- }
- if (!unsafeProtocol[lowerProto])
- for (var i = 0, l = autoEscape.length;i < l; i++) {
- var ae = autoEscape[i];
- if (rest.indexOf(ae) === -1)
- continue;
- var esc = encodeURIComponent(ae);
- if (esc === ae)
- esc = escape(ae);
- rest = rest.split(ae).join(esc);
- }
- var hash = rest.indexOf("#");
- if (hash !== -1)
- this.hash = rest.substr(hash), rest = rest.slice(0, hash);
- var qm = rest.indexOf("?");
- if (qm !== -1) {
- if (this.search = rest.substr(qm), this.query = rest.substr(qm + 1), parseQueryString)
- this.query = new URLSearchParams(this.query);
- rest = rest.slice(0, qm);
- } else if (parseQueryString)
- this.search = "", this.query = {};
- if (rest)
- this.pathname = rest;
- if (slashedProtocol[lowerProto] && this.hostname && !this.pathname)
- this.pathname = "/";
- if (this.pathname || this.search) {
- var p = this.pathname || "", s = this.search || "";
- this.path = p + s;
- }
- return this.href = this.format(), this;
-};
-Url.prototype.format = function() {
- var auth = this.auth || "";
- if (auth)
- auth = encodeURIComponent(auth), auth = auth.replace(/%3A/i, ":"), auth += "@";
- var protocol = this.protocol || "", pathname = this.pathname || "", hash = this.hash || "", host = !1, query = "";
- if (this.host)
- host = auth + this.host;
- else if (this.hostname) {
- if (host = auth + (this.hostname.indexOf(":") === -1 ? this.hostname : "[" + this.hostname + "]"), this.port)
- host += ":" + this.port;
- }
- if (this.query && typeof this.query === "object" && Object.keys(this.query).length)
- query = new URLSearchParams(this.query).toString();
- var search = this.search || query && "?" + query || "";
- if (protocol && protocol.substr(-1) !== ":")
- protocol += ":";
- if (this.slashes || (!protocol || slashedProtocol[protocol]) && host !== !1) {
- if (host = "//" + (host || ""), pathname && pathname.charAt(0) !== "/")
- pathname = "/" + pathname;
- } else if (!host)
- host = "";
- if (hash && hash.charAt(0) !== "#")
- hash = "#" + hash;
- if (search && search.charAt(0) !== "?")
- search = "?" + search;
- return pathname = pathname.replace(/[?#]/g, function(match) {
- return encodeURIComponent(match);
- }), search = search.replace("#", "%23"), protocol + host + pathname + search + hash;
-};
-Url.prototype.resolve = function(relative) {
- return this.resolveObject(urlParse(relative, !1, !0)).format();
-};
-Url.prototype.resolveObject = function(relative) {
- if (typeof relative === "string") {
- var rel = new Url;
- rel.parse(relative, !1, !0), relative = rel;
- }
- var result = new Url, tkeys = Object.keys(this);
- for (var tk = 0;tk < tkeys.length; tk++) {
- var tkey = tkeys[tk];
- result[tkey] = this[tkey];
- }
- if (result.hash = relative.hash, relative.href === "")
- return result.href = result.format(), result;
- if (relative.slashes && !relative.protocol) {
- var rkeys = Object.keys(relative);
- for (var rk = 0;rk < rkeys.length; rk++) {
- var rkey = rkeys[rk];
- if (rkey !== "protocol")
- result[rkey] = relative[rkey];
- }
- if (slashedProtocol[result.protocol] && result.hostname && !result.pathname)
- result.pathname = "/", result.path = result.pathname;
- return result.href = result.format(), result;
- }
- if (relative.protocol && relative.protocol !== result.protocol) {
- if (!slashedProtocol[relative.protocol]) {
- var keys = Object.keys(relative);
- for (var v = 0;v < keys.length; v++) {
- var k = keys[v];
- result[k] = relative[k];
- }
- return result.href = result.format(), result;
- }
- if (result.protocol = relative.protocol, !relative.host && !hostlessProtocol[relative.protocol]) {
- var relPath = (relative.pathname || "").split("/");
- while (relPath.length && !(relative.host = relPath.shift()))
- ;
- if (!relative.host)
- relative.host = "";
- if (!relative.hostname)
- relative.hostname = "";
- if (relPath[0] !== "")
- relPath.unshift("");
- if (relPath.length < 2)
- relPath.unshift("");
- result.pathname = relPath.join("/");
- } else
- result.pathname = relative.pathname;
- if (result.search = relative.search, result.query = relative.query, result.host = relative.host || "", result.auth = relative.auth, result.hostname = relative.hostname || relative.host, result.port = relative.port, result.pathname || result.search) {
- var p = result.pathname || "", s = result.search || "";
- result.path = p + s;
- }
- return result.slashes = result.slashes || relative.slashes, result.href = result.format(), result;
- }
- var isSourceAbs = result.pathname && result.pathname.charAt(0) === "/", isRelAbs = relative.host || relative.pathname && relative.pathname.charAt(0) === "/", mustEndAbs = isRelAbs || isSourceAbs || result.host && relative.pathname, removeAllDots = mustEndAbs, srcPath = result.pathname && result.pathname.split("/") || [], relPath = relative.pathname && relative.pathname.split("/") || [], psychotic = result.protocol && !slashedProtocol[result.protocol];
- if (psychotic) {
- if (result.hostname = "", result.port = null, result.host)
- if (srcPath[0] === "")
- srcPath[0] = result.host;
- else
- srcPath.unshift(result.host);
- if (result.host = "", relative.protocol) {
- if (relative.hostname = null, relative.port = null, relative.host)
- if (relPath[0] === "")
- relPath[0] = relative.host;
- else
- relPath.unshift(relative.host);
- relative.host = null;
- }
- mustEndAbs = mustEndAbs && (relPath[0] === "" || srcPath[0] === "");
- }
- if (isRelAbs)
- result.host = relative.host || relative.host === "" ? relative.host : result.host, result.hostname = relative.hostname || relative.hostname === "" ? relative.hostname : result.hostname, result.search = relative.search, result.query = relative.query, srcPath = relPath;
- else if (relPath.length) {
- if (!srcPath)
- srcPath = [];
- srcPath.pop(), srcPath = srcPath.concat(relPath), result.search = relative.search, result.query = relative.query;
- } else if (relative.search != null) {
- if (psychotic) {
- result.host = srcPath.shift(), result.hostname = result.host;
- var authInHost = result.host && result.host.indexOf("@") > 0 ? result.host.split("@") : !1;
- if (authInHost)
- result.auth = authInHost.shift(), result.hostname = authInHost.shift(), result.host = result.hostname;
- }
- if (result.search = relative.search, result.query = relative.query, result.pathname !== null || result.search !== null)
- result.path = (result.pathname ? result.pathname : "") + (result.search ? result.search : "");
- return result.href = result.format(), result;
- }
- if (!srcPath.length) {
- if (result.pathname = null, result.search)
- result.path = "/" + result.search;
- else
- result.path = null;
- return result.href = result.format(), result;
- }
- var last = srcPath.slice(-1)[0], hasTrailingSlash = (result.host || relative.host || srcPath.length > 1) && (last === "." || last === "..") || last === "", up = 0;
- for (var i = srcPath.length;i >= 0; i--)
- if (last = srcPath[i], last === ".")
- srcPath.splice(i, 1);
- else if (last === "..")
- srcPath.splice(i, 1), up++;
- else if (up)
- srcPath.splice(i, 1), up--;
- if (!mustEndAbs && !removeAllDots)
- for (;up--; up)
- srcPath.unshift("..");
- if (mustEndAbs && srcPath[0] !== "" && (!srcPath[0] || srcPath[0].charAt(0) !== "/"))
- srcPath.unshift("");
- if (hasTrailingSlash && srcPath.join("/").substr(-1) !== "/")
- srcPath.push("");
- var isAbsolute = srcPath[0] === "" || srcPath[0] && srcPath[0].charAt(0) === "/";
- if (psychotic) {
- result.hostname = isAbsolute ? "" : srcPath.length ? srcPath.shift() : "", result.host = result.hostname;
- var authInHost = result.host && result.host.indexOf("@") > 0 ? result.host.split("@") : !1;
- if (authInHost)
- result.auth = authInHost.shift(), result.hostname = authInHost.shift(), result.host = result.hostname;
- }
- if (mustEndAbs = mustEndAbs || result.host && srcPath.length, mustEndAbs && !isAbsolute)
- srcPath.unshift("");
- if (srcPath.length > 0)
- result.pathname = srcPath.join("/");
- else
- result.pathname = null, result.path = null;
- if (result.pathname !== null || result.search !== null)
- result.path = (result.pathname ? result.pathname : "") + (result.search ? result.search : "");
- return result.auth = relative.auth || result.auth, result.slashes = result.slashes || relative.slashes, result.href = result.format(), result;
-};
-Url.prototype.parseHost = function() {
- var host = this.host, port = portPattern.exec(host);
- if (port) {
- if (port = port[0], port !== ":")
- this.port = port.substr(1);
- host = host.substr(0, host.length - port.length);
- }
- if (host)
- this.hostname = host;
-};
-var lazy = globalThis[Symbol.for("Bun.lazy")], pathToFileURL = lazy("pathToFileURL"), fileURLToPath = lazy("fileURLToPath"), defaultObject = {
- parse: urlParse,
- resolve: urlResolve,
- resolveObject: urlResolveObject,
- format: urlFormat,
- Url,
- URLSearchParams,
- URL,
- pathToFileURL,
- fileURLToPath,
- urlToHttpOptions
-};
-export {
- urlToHttpOptions,
- urlResolveObject as resolveObject,
- urlResolve as resolve,
- pathToFileURL,
- urlParse as parse,
- urlFormat as format,
- fileURLToPath,
- defaultObject as default,
- Url,
- URLSearchParams,
- URL
-};
+var $=function(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null},g=function(N,J,f){if(N&&typeof N==="object"&&N instanceof $)return N;var X=new $;return X.parse(N,J,f),X},t=function(N){if(typeof N==="string")N=g(N);if(!(N instanceof $))return $.prototype.format.call(N);return N.format()},ff=function(N,J){return g(N,!1,!0).resolve(J)},Nf=function(N,J){if(!N)return J;return g(N,!1,!0).resolveObject(J)},Bf=function(N){const J={protocol:N.protocol,hostname:typeof N.hostname==="string"&&N.hostname.startsWith("[")?N.hostname.slice(1,-1):N.hostname,hash:N.hash,search:N.search,pathname:N.pathname,path:`${N.pathname||""}${N.search||""}`,href:N.href};if(N.port!=="")J.port=Number(N.port);if(N.username||N.password)J.auth=`${decodeURIComponent(N.username)}:${decodeURIComponent(N.password)}`;return J},{URL:n,URLSearchParams:S}=globalThis,i=/^([a-z0-9.+-]+:)/i,o=/:[0-9]*$/,u=/^(\/\/?(?!\/)[^?\s]*)(\?[^\s]*)?$/,a=["<",">",'"',"`"," ","\r","\n","\t"],l=["{","}","|","\\","^","`"].concat(a),E=["'"].concat(l),m=["%","/","?",";","#"].concat(E),c=["/","?","#"],s=255,P=/^[+a-z0-9A-Z_-]{0,63}$/,r=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,e={javascript:!0,"javascript:":!0},d={javascript:!0,"javascript:":!0},Q={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0};$.prototype.parse=function(N,J,f){if(typeof N!=="string")throw new TypeError("Parameter 'url' must be a string, not "+typeof N);var X=N.indexOf("?"),V=X!==-1&&X<N.indexOf("#")?"?":"#",x=N.split(V),_=/\\/g;x[0]=x[0].replace(_,"/"),N=x.join(V);var B=N;if(B=B.trim(),!f&&N.split("#").length===1){var T=u.exec(B);if(T){if(this.path=B,this.href=B,this.pathname=T[1],T[2])if(this.search=T[2],J)this.query=new S(this.search.substr(1)).toJSON();else this.query=this.search.substr(1);else if(J)this.search="",this.query={};return this}}var Y=i.exec(B);if(Y){Y=Y[0];var I=Y.toLowerCase();this.protocol=I,B=B.substr(Y.length)}if(f||Y||B.match(/^\/\/[^@/]+@[^@/]+/)){var w=B.substr(0,2)==="//";if(w&&!(Y&&d[Y]))B=B.substr(2),this.slashes=!0}if(!d[Y]&&(w||Y&&!Q[Y])){var W=-1;for(var K=0;K<c.length;K++){var D=B.indexOf(c[K]);if(D!==-1&&(W===-1||D<W))W=D}var A,Z;if(W===-1)Z=B.lastIndexOf("@");else Z=B.lastIndexOf("@",W);if(Z!==-1)A=B.slice(0,Z),B=B.slice(Z+1),this.auth=decodeURIComponent(A);W=-1;for(var K=0;K<m.length;K++){var D=B.indexOf(m[K]);if(D!==-1&&(W===-1||D<W))W=D}if(W===-1)W=B.length;this.host=B.slice(0,W),B=B.slice(W),this.parseHost(),this.hostname=this.hostname||"";var R=this.hostname[0]==="["&&this.hostname[this.hostname.length-1]==="]";if(!R){var G=this.hostname.split(/\./);for(var K=0,M=G.length;K<M;K++){var F=G[K];if(!F)continue;if(!F.match(P)){var z="";for(var C=0,H=F.length;C<H;C++)if(F.charCodeAt(C)>127)z+="x";else z+=F[C];if(!z.match(P)){var q=G.slice(0,K),O=G.slice(K+1),L=F.match(r);if(L)q.push(L[1]),O.unshift(L[2]);if(O.length)B="/"+O.join(".")+B;this.hostname=q.join(".");break}}}}if(this.hostname.length>s)this.hostname="";else this.hostname=this.hostname.toLowerCase();if(!R)this.hostname=new n("http://"+this.hostname).hostname;var b=this.port?":"+this.port:"",v=this.hostname||"";if(this.host=v+b,this.href+=this.host,R){if(this.hostname=this.hostname.substr(1,this.hostname.length-2),B[0]!=="/")B="/"+B}}if(!e[I])for(var K=0,M=E.length;K<M;K++){var j=E[K];if(B.indexOf(j)===-1)continue;var y=encodeURIComponent(j);if(y===j)y=escape(j);B=B.split(j).join(y)}var k=B.indexOf("#");if(k!==-1)this.hash=B.substr(k),B=B.slice(0,k);var U=B.indexOf("?");if(U!==-1){if(this.search=B.substr(U),this.query=B.substr(U+1),J)this.query=new S(this.query);B=B.slice(0,U)}else if(J)this.search="",this.query={};if(B)this.pathname=B;if(Q[I]&&this.hostname&&!this.pathname)this.pathname="/";if(this.pathname||this.search){var b=this.pathname||"",h=this.search||"";this.path=b+h}return this.href=this.format(),this};$.prototype.format=function(){var N=this.auth||"";if(N)N=encodeURIComponent(N),N=N.replace(/%3A/i,":"),N+="@";var J=this.protocol||"",f=this.pathname||"",X=this.hash||"",V=!1,x="";if(this.host)V=N+this.host;else if(this.hostname){if(V=N+(this.hostname.indexOf(":")===-1?this.hostname:"["+this.hostname+"]"),this.port)V+=":"+this.port}if(this.query&&typeof this.query==="object"&&Object.keys(this.query).length)x=new S(this.query).toString();var _=this.search||x&&"?"+x||"";if(J&&J.substr(-1)!==":")J+=":";if(this.slashes||(!J||Q[J])&&V!==!1){if(V="//"+(V||""),f&&f.charAt(0)!=="/")f="/"+f}else if(!V)V="";if(X&&X.charAt(0)!=="#")X="#"+X;if(_&&_.charAt(0)!=="?")_="?"+_;return f=f.replace(/[?#]/g,function(B){return encodeURIComponent(B)}),_=_.replace("#","%23"),J+V+f+_+X};$.prototype.resolve=function(N){return this.resolveObject(g(N,!1,!0)).format()};$.prototype.resolveObject=function(N){if(typeof N==="string"){var J=new $;J.parse(N,!1,!0),N=J}var f=new $,X=Object.keys(this);for(var V=0;V<X.length;V++){var x=X[V];f[x]=this[x]}if(f.hash=N.hash,N.href==="")return f.href=f.format(),f;if(N.slashes&&!N.protocol){var _=Object.keys(N);for(var B=0;B<_.length;B++){var T=_[B];if(T!=="protocol")f[T]=N[T]}if(Q[f.protocol]&&f.hostname&&!f.pathname)f.pathname="/",f.path=f.pathname;return f.href=f.format(),f}if(N.protocol&&N.protocol!==f.protocol){if(!Q[N.protocol]){var Y=Object.keys(N);for(var I=0;I<Y.length;I++){var w=Y[I];f[w]=N[w]}return f.href=f.format(),f}if(f.protocol=N.protocol,!N.host&&!d[N.protocol]){var M=(N.pathname||"").split("/");while(M.length&&!(N.host=M.shift()));if(!N.host)N.host="";if(!N.hostname)N.hostname="";if(M[0]!=="")M.unshift("");if(M.length<2)M.unshift("");f.pathname=M.join("/")}else f.pathname=N.pathname;if(f.search=N.search,f.query=N.query,f.host=N.host||"",f.auth=N.auth,f.hostname=N.hostname||N.host,f.port=N.port,f.pathname||f.search){var W=f.pathname||"",K=f.search||"";f.path=W+K}return f.slashes=f.slashes||N.slashes,f.href=f.format(),f}var D=f.pathname&&f.pathname.charAt(0)==="/",A=N.host||N.pathname&&N.pathname.charAt(0)==="/",Z=A||D||f.host&&N.pathname,R=Z,G=f.pathname&&f.pathname.split("/")||[],M=N.pathname&&N.pathname.split("/")||[],F=f.protocol&&!Q[f.protocol];if(F){if(f.hostname="",f.port=null,f.host)if(G[0]==="")G[0]=f.host;else G.unshift(f.host);if(f.host="",N.protocol){if(N.hostname=null,N.port=null,N.host)if(M[0]==="")M[0]=N.host;else M.unshift(N.host);N.host=null}Z=Z&&(M[0]===""||G[0]==="")}if(A)f.host=N.host||N.host===""?N.host:f.host,f.hostname=N.hostname||N.hostname===""?N.hostname:f.hostname,f.search=N.search,f.query=N.query,G=M;else if(M.length){if(!G)G=[];G.pop(),G=G.concat(M),f.search=N.search,f.query=N.query}else if(N.search!=null){if(F){f.host=G.shift(),f.hostname=f.host;var z=f.host&&f.host.indexOf("@")>0?f.host.split("@"):!1;if(z)f.auth=z.shift(),f.hostname=z.shift(),f.host=f.hostname}if(f.search=N.search,f.query=N.query,f.pathname!==null||f.search!==null)f.path=(f.pathname?f.pathname:"")+(f.search?f.search:"");return f.href=f.format(),f}if(!G.length){if(f.pathname=null,f.search)f.path="/"+f.search;else f.path=null;return f.href=f.format(),f}var C=G.slice(-1)[0],H=(f.host||N.host||G.length>1)&&(C==="."||C==="..")||C==="",q=0;for(var O=G.length;O>=0;O--)if(C=G[O],C===".")G.splice(O,1);else if(C==="..")G.splice(O,1),q++;else if(q)G.splice(O,1),q--;if(!Z&&!R)for(;q--;q)G.unshift("..");if(Z&&G[0]!==""&&(!G[0]||G[0].charAt(0)!=="/"))G.unshift("");if(H&&G.join("/").substr(-1)!=="/")G.push("");var L=G[0]===""||G[0]&&G[0].charAt(0)==="/";if(F){f.hostname=L?"":G.length?G.shift():"",f.host=f.hostname;var z=f.host&&f.host.indexOf("@")>0?f.host.split("@"):!1;if(z)f.auth=z.shift(),f.hostname=z.shift(),f.host=f.hostname}if(Z=Z||f.host&&G.length,Z&&!L)G.unshift("");if(G.length>0)f.pathname=G.join("/");else f.pathname=null,f.path=null;if(f.pathname!==null||f.search!==null)f.path=(f.pathname?f.pathname:"")+(f.search?f.search:"");return f.auth=N.auth||f.auth,f.slashes=f.slashes||N.slashes,f.href=f.format(),f};$.prototype.parseHost=function(){var N=this.host,J=o.exec(N);if(J){if(J=J[0],J!==":")this.port=J.substr(1);N=N.substr(0,N.length-J.length)}if(N)this.hostname=N};var p=globalThis[Symbol.for("Bun.lazy")],Gf=p("pathToFileURL"),Jf=p("fileURLToPath"),Kf={parse:g,resolve:ff,resolveObject:Nf,format:t,Url:$,URLSearchParams:S,URL:n,pathToFileURL:Gf,fileURLToPath:Jf,urlToHttpOptions:Bf,[Symbol.for("CommonJS")]:0};export{Bf as urlToHttpOptions,Nf as resolveObject,ff as resolve,Gf as pathToFileURL,g as parse,t as format,Jf as fileURLToPath,Kf as default,$ as Url,S as URLSearchParams,n as URL};