url-DXYD2UK6.js 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851
  1. import {
  2. __commonJS
  3. } from "./chunk-S5KM4IGW.js";
  4. // node_modules/url/node_modules/punycode/punycode.js
  5. var require_punycode = __commonJS({
  6. "node_modules/url/node_modules/punycode/punycode.js"(exports, module) {
  7. (function(root) {
  8. var freeExports = typeof exports == "object" && exports && !exports.nodeType && exports;
  9. var freeModule = typeof module == "object" && module && !module.nodeType && module;
  10. var freeGlobal = typeof global == "object" && global;
  11. if (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal || freeGlobal.self === freeGlobal) {
  12. root = freeGlobal;
  13. }
  14. var punycode, maxInt = 2147483647, base = 36, tMin = 1, tMax = 26, skew = 38, damp = 700, initialBias = 72, initialN = 128, delimiter = "-", regexPunycode = /^xn--/, regexNonASCII = /[^\x20-\x7E]/, regexSeparators = /[\x2E\u3002\uFF0E\uFF61]/g, errors = {
  15. "overflow": "Overflow: input needs wider integers to process",
  16. "not-basic": "Illegal input >= 0x80 (not a basic code point)",
  17. "invalid-input": "Invalid input"
  18. }, baseMinusTMin = base - tMin, floor = Math.floor, stringFromCharCode = String.fromCharCode, key;
  19. function error(type) {
  20. throw RangeError(errors[type]);
  21. }
  22. function map(array, fn) {
  23. var length = array.length;
  24. var result = [];
  25. while (length--) {
  26. result[length] = fn(array[length]);
  27. }
  28. return result;
  29. }
  30. function mapDomain(string, fn) {
  31. var parts = string.split("@");
  32. var result = "";
  33. if (parts.length > 1) {
  34. result = parts[0] + "@";
  35. string = parts[1];
  36. }
  37. string = string.replace(regexSeparators, ".");
  38. var labels = string.split(".");
  39. var encoded = map(labels, fn).join(".");
  40. return result + encoded;
  41. }
  42. function ucs2decode(string) {
  43. var output = [], counter = 0, length = string.length, value, extra;
  44. while (counter < length) {
  45. value = string.charCodeAt(counter++);
  46. if (value >= 55296 && value <= 56319 && counter < length) {
  47. extra = string.charCodeAt(counter++);
  48. if ((extra & 64512) == 56320) {
  49. output.push(((value & 1023) << 10) + (extra & 1023) + 65536);
  50. } else {
  51. output.push(value);
  52. counter--;
  53. }
  54. } else {
  55. output.push(value);
  56. }
  57. }
  58. return output;
  59. }
  60. function ucs2encode(array) {
  61. return map(array, function(value) {
  62. var output = "";
  63. if (value > 65535) {
  64. value -= 65536;
  65. output += stringFromCharCode(value >>> 10 & 1023 | 55296);
  66. value = 56320 | value & 1023;
  67. }
  68. output += stringFromCharCode(value);
  69. return output;
  70. }).join("");
  71. }
  72. function basicToDigit(codePoint) {
  73. if (codePoint - 48 < 10) {
  74. return codePoint - 22;
  75. }
  76. if (codePoint - 65 < 26) {
  77. return codePoint - 65;
  78. }
  79. if (codePoint - 97 < 26) {
  80. return codePoint - 97;
  81. }
  82. return base;
  83. }
  84. function digitToBasic(digit, flag) {
  85. return digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5);
  86. }
  87. function adapt(delta, numPoints, firstTime) {
  88. var k = 0;
  89. delta = firstTime ? floor(delta / damp) : delta >> 1;
  90. delta += floor(delta / numPoints);
  91. for (; delta > baseMinusTMin * tMax >> 1; k += base) {
  92. delta = floor(delta / baseMinusTMin);
  93. }
  94. return floor(k + (baseMinusTMin + 1) * delta / (delta + skew));
  95. }
  96. function decode(input) {
  97. var output = [], inputLength = input.length, out, i = 0, n = initialN, bias = initialBias, basic, j, index, oldi, w, k, digit, t, baseMinusT;
  98. basic = input.lastIndexOf(delimiter);
  99. if (basic < 0) {
  100. basic = 0;
  101. }
  102. for (j = 0; j < basic; ++j) {
  103. if (input.charCodeAt(j) >= 128) {
  104. error("not-basic");
  105. }
  106. output.push(input.charCodeAt(j));
  107. }
  108. for (index = basic > 0 ? basic + 1 : 0; index < inputLength; ) {
  109. for (oldi = i, w = 1, k = base; ; k += base) {
  110. if (index >= inputLength) {
  111. error("invalid-input");
  112. }
  113. digit = basicToDigit(input.charCodeAt(index++));
  114. if (digit >= base || digit > floor((maxInt - i) / w)) {
  115. error("overflow");
  116. }
  117. i += digit * w;
  118. t = k <= bias ? tMin : k >= bias + tMax ? tMax : k - bias;
  119. if (digit < t) {
  120. break;
  121. }
  122. baseMinusT = base - t;
  123. if (w > floor(maxInt / baseMinusT)) {
  124. error("overflow");
  125. }
  126. w *= baseMinusT;
  127. }
  128. out = output.length + 1;
  129. bias = adapt(i - oldi, out, oldi == 0);
  130. if (floor(i / out) > maxInt - n) {
  131. error("overflow");
  132. }
  133. n += floor(i / out);
  134. i %= out;
  135. output.splice(i++, 0, n);
  136. }
  137. return ucs2encode(output);
  138. }
  139. function encode(input) {
  140. var n, delta, handledCPCount, basicLength, bias, j, m, q, k, t, currentValue, output = [], inputLength, handledCPCountPlusOne, baseMinusT, qMinusT;
  141. input = ucs2decode(input);
  142. inputLength = input.length;
  143. n = initialN;
  144. delta = 0;
  145. bias = initialBias;
  146. for (j = 0; j < inputLength; ++j) {
  147. currentValue = input[j];
  148. if (currentValue < 128) {
  149. output.push(stringFromCharCode(currentValue));
  150. }
  151. }
  152. handledCPCount = basicLength = output.length;
  153. if (basicLength) {
  154. output.push(delimiter);
  155. }
  156. while (handledCPCount < inputLength) {
  157. for (m = maxInt, j = 0; j < inputLength; ++j) {
  158. currentValue = input[j];
  159. if (currentValue >= n && currentValue < m) {
  160. m = currentValue;
  161. }
  162. }
  163. handledCPCountPlusOne = handledCPCount + 1;
  164. if (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) {
  165. error("overflow");
  166. }
  167. delta += (m - n) * handledCPCountPlusOne;
  168. n = m;
  169. for (j = 0; j < inputLength; ++j) {
  170. currentValue = input[j];
  171. if (currentValue < n && ++delta > maxInt) {
  172. error("overflow");
  173. }
  174. if (currentValue == n) {
  175. for (q = delta, k = base; ; k += base) {
  176. t = k <= bias ? tMin : k >= bias + tMax ? tMax : k - bias;
  177. if (q < t) {
  178. break;
  179. }
  180. qMinusT = q - t;
  181. baseMinusT = base - t;
  182. output.push(
  183. stringFromCharCode(digitToBasic(t + qMinusT % baseMinusT, 0))
  184. );
  185. q = floor(qMinusT / baseMinusT);
  186. }
  187. output.push(stringFromCharCode(digitToBasic(q, 0)));
  188. bias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength);
  189. delta = 0;
  190. ++handledCPCount;
  191. }
  192. }
  193. ++delta;
  194. ++n;
  195. }
  196. return output.join("");
  197. }
  198. function toUnicode(input) {
  199. return mapDomain(input, function(string) {
  200. return regexPunycode.test(string) ? decode(string.slice(4).toLowerCase()) : string;
  201. });
  202. }
  203. function toASCII(input) {
  204. return mapDomain(input, function(string) {
  205. return regexNonASCII.test(string) ? "xn--" + encode(string) : string;
  206. });
  207. }
  208. punycode = {
  209. "version": "1.3.2",
  210. "ucs2": {
  211. "decode": ucs2decode,
  212. "encode": ucs2encode
  213. },
  214. "decode": decode,
  215. "encode": encode,
  216. "toASCII": toASCII,
  217. "toUnicode": toUnicode
  218. };
  219. if (typeof define == "function" && typeof define.amd == "object" && define.amd) {
  220. define("punycode", function() {
  221. return punycode;
  222. });
  223. } else if (freeExports && freeModule) {
  224. if (module.exports == freeExports) {
  225. freeModule.exports = punycode;
  226. } else {
  227. for (key in punycode) {
  228. punycode.hasOwnProperty(key) && (freeExports[key] = punycode[key]);
  229. }
  230. }
  231. } else {
  232. root.punycode = punycode;
  233. }
  234. })(exports);
  235. }
  236. });
  237. // node_modules/url/util.js
  238. var require_util = __commonJS({
  239. "node_modules/url/util.js"(exports, module) {
  240. "use strict";
  241. module.exports = {
  242. isString: function(arg) {
  243. return typeof arg === "string";
  244. },
  245. isObject: function(arg) {
  246. return typeof arg === "object" && arg !== null;
  247. },
  248. isNull: function(arg) {
  249. return arg === null;
  250. },
  251. isNullOrUndefined: function(arg) {
  252. return arg == null;
  253. }
  254. };
  255. }
  256. });
  257. // node_modules/querystring/decode.js
  258. var require_decode = __commonJS({
  259. "node_modules/querystring/decode.js"(exports, module) {
  260. "use strict";
  261. function hasOwnProperty(obj, prop) {
  262. return Object.prototype.hasOwnProperty.call(obj, prop);
  263. }
  264. module.exports = function(qs, sep, eq, options) {
  265. sep = sep || "&";
  266. eq = eq || "=";
  267. var obj = {};
  268. if (typeof qs !== "string" || qs.length === 0) {
  269. return obj;
  270. }
  271. var regexp = /\+/g;
  272. qs = qs.split(sep);
  273. var maxKeys = 1e3;
  274. if (options && typeof options.maxKeys === "number") {
  275. maxKeys = options.maxKeys;
  276. }
  277. var len = qs.length;
  278. if (maxKeys > 0 && len > maxKeys) {
  279. len = maxKeys;
  280. }
  281. for (var i = 0; i < len; ++i) {
  282. var x = qs[i].replace(regexp, "%20"), idx = x.indexOf(eq), kstr, vstr, k, v;
  283. if (idx >= 0) {
  284. kstr = x.substr(0, idx);
  285. vstr = x.substr(idx + 1);
  286. } else {
  287. kstr = x;
  288. vstr = "";
  289. }
  290. k = decodeURIComponent(kstr);
  291. v = decodeURIComponent(vstr);
  292. if (!hasOwnProperty(obj, k)) {
  293. obj[k] = v;
  294. } else if (Array.isArray(obj[k])) {
  295. obj[k].push(v);
  296. } else {
  297. obj[k] = [obj[k], v];
  298. }
  299. }
  300. return obj;
  301. };
  302. }
  303. });
  304. // node_modules/querystring/encode.js
  305. var require_encode = __commonJS({
  306. "node_modules/querystring/encode.js"(exports, module) {
  307. "use strict";
  308. var stringifyPrimitive = function(v) {
  309. switch (typeof v) {
  310. case "string":
  311. return v;
  312. case "boolean":
  313. return v ? "true" : "false";
  314. case "number":
  315. return isFinite(v) ? v : "";
  316. default:
  317. return "";
  318. }
  319. };
  320. module.exports = function(obj, sep, eq, name) {
  321. sep = sep || "&";
  322. eq = eq || "=";
  323. if (obj === null) {
  324. obj = void 0;
  325. }
  326. if (typeof obj === "object") {
  327. return Object.keys(obj).map(function(k) {
  328. var ks = encodeURIComponent(stringifyPrimitive(k)) + eq;
  329. if (Array.isArray(obj[k])) {
  330. return obj[k].map(function(v) {
  331. return ks + encodeURIComponent(stringifyPrimitive(v));
  332. }).join(sep);
  333. } else {
  334. return ks + encodeURIComponent(stringifyPrimitive(obj[k]));
  335. }
  336. }).join(sep);
  337. }
  338. if (!name)
  339. return "";
  340. return encodeURIComponent(stringifyPrimitive(name)) + eq + encodeURIComponent(stringifyPrimitive(obj));
  341. };
  342. }
  343. });
  344. // node_modules/querystring/index.js
  345. var require_querystring = __commonJS({
  346. "node_modules/querystring/index.js"(exports) {
  347. "use strict";
  348. exports.decode = exports.parse = require_decode();
  349. exports.encode = exports.stringify = require_encode();
  350. }
  351. });
  352. // node_modules/url/url.js
  353. var require_url = __commonJS({
  354. "node_modules/url/url.js"(exports) {
  355. var punycode = require_punycode();
  356. var util = require_util();
  357. exports.parse = urlParse;
  358. exports.resolve = urlResolve;
  359. exports.resolveObject = urlResolveObject;
  360. exports.format = urlFormat;
  361. exports.Url = Url;
  362. function Url() {
  363. this.protocol = null;
  364. this.slashes = null;
  365. this.auth = null;
  366. this.host = null;
  367. this.port = null;
  368. this.hostname = null;
  369. this.hash = null;
  370. this.search = null;
  371. this.query = null;
  372. this.pathname = null;
  373. this.path = null;
  374. this.href = null;
  375. }
  376. var protocolPattern = /^([a-z0-9.+-]+:)/i;
  377. var portPattern = /:[0-9]*$/;
  378. var simplePathPattern = /^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/;
  379. var delims = ["<", ">", '"', "`", " ", "\r", "\n", " "];
  380. var unwise = ["{", "}", "|", "\\", "^", "`"].concat(delims);
  381. var autoEscape = ["'"].concat(unwise);
  382. var nonHostChars = ["%", "/", "?", ";", "#"].concat(autoEscape);
  383. var hostEndingChars = ["/", "?", "#"];
  384. var hostnameMaxLen = 255;
  385. var hostnamePartPattern = /^[+a-z0-9A-Z_-]{0,63}$/;
  386. var hostnamePartStart = /^([+a-z0-9A-Z_-]{0,63})(.*)$/;
  387. var unsafeProtocol = {
  388. "javascript": true,
  389. "javascript:": true
  390. };
  391. var hostlessProtocol = {
  392. "javascript": true,
  393. "javascript:": true
  394. };
  395. var slashedProtocol = {
  396. "http": true,
  397. "https": true,
  398. "ftp": true,
  399. "gopher": true,
  400. "file": true,
  401. "http:": true,
  402. "https:": true,
  403. "ftp:": true,
  404. "gopher:": true,
  405. "file:": true
  406. };
  407. var querystring = require_querystring();
  408. function urlParse(url, parseQueryString, slashesDenoteHost) {
  409. if (url && util.isObject(url) && url instanceof Url)
  410. return url;
  411. var u = new Url();
  412. u.parse(url, parseQueryString, slashesDenoteHost);
  413. return u;
  414. }
  415. Url.prototype.parse = function(url, parseQueryString, slashesDenoteHost) {
  416. if (!util.isString(url)) {
  417. throw new TypeError("Parameter 'url' must be a string, not " + typeof url);
  418. }
  419. var queryIndex = url.indexOf("?"), splitter = queryIndex !== -1 && queryIndex < url.indexOf("#") ? "?" : "#", uSplit = url.split(splitter), slashRegex = /\\/g;
  420. uSplit[0] = uSplit[0].replace(slashRegex, "/");
  421. url = uSplit.join(splitter);
  422. var rest = url;
  423. rest = rest.trim();
  424. if (!slashesDenoteHost && url.split("#").length === 1) {
  425. var simplePath = simplePathPattern.exec(rest);
  426. if (simplePath) {
  427. this.path = rest;
  428. this.href = rest;
  429. this.pathname = simplePath[1];
  430. if (simplePath[2]) {
  431. this.search = simplePath[2];
  432. if (parseQueryString) {
  433. this.query = querystring.parse(this.search.substr(1));
  434. } else {
  435. this.query = this.search.substr(1);
  436. }
  437. } else if (parseQueryString) {
  438. this.search = "";
  439. this.query = {};
  440. }
  441. return this;
  442. }
  443. }
  444. var proto = protocolPattern.exec(rest);
  445. if (proto) {
  446. proto = proto[0];
  447. var lowerProto = proto.toLowerCase();
  448. this.protocol = lowerProto;
  449. rest = rest.substr(proto.length);
  450. }
  451. if (slashesDenoteHost || proto || rest.match(/^\/\/[^@\/]+@[^@\/]+/)) {
  452. var slashes = rest.substr(0, 2) === "//";
  453. if (slashes && !(proto && hostlessProtocol[proto])) {
  454. rest = rest.substr(2);
  455. this.slashes = true;
  456. }
  457. }
  458. if (!hostlessProtocol[proto] && (slashes || proto && !slashedProtocol[proto])) {
  459. var hostEnd = -1;
  460. for (var i = 0; i < hostEndingChars.length; i++) {
  461. var hec = rest.indexOf(hostEndingChars[i]);
  462. if (hec !== -1 && (hostEnd === -1 || hec < hostEnd))
  463. hostEnd = hec;
  464. }
  465. var auth, atSign;
  466. if (hostEnd === -1) {
  467. atSign = rest.lastIndexOf("@");
  468. } else {
  469. atSign = rest.lastIndexOf("@", hostEnd);
  470. }
  471. if (atSign !== -1) {
  472. auth = rest.slice(0, atSign);
  473. rest = rest.slice(atSign + 1);
  474. this.auth = decodeURIComponent(auth);
  475. }
  476. hostEnd = -1;
  477. for (var i = 0; i < nonHostChars.length; i++) {
  478. var hec = rest.indexOf(nonHostChars[i]);
  479. if (hec !== -1 && (hostEnd === -1 || hec < hostEnd))
  480. hostEnd = hec;
  481. }
  482. if (hostEnd === -1)
  483. hostEnd = rest.length;
  484. this.host = rest.slice(0, hostEnd);
  485. rest = rest.slice(hostEnd);
  486. this.parseHost();
  487. this.hostname = this.hostname || "";
  488. var ipv6Hostname = this.hostname[0] === "[" && this.hostname[this.hostname.length - 1] === "]";
  489. if (!ipv6Hostname) {
  490. var hostparts = this.hostname.split(/\./);
  491. for (var i = 0, l = hostparts.length; i < l; i++) {
  492. var part = hostparts[i];
  493. if (!part)
  494. continue;
  495. if (!part.match(hostnamePartPattern)) {
  496. var newpart = "";
  497. for (var j = 0, k = part.length; j < k; j++) {
  498. if (part.charCodeAt(j) > 127) {
  499. newpart += "x";
  500. } else {
  501. newpart += part[j];
  502. }
  503. }
  504. if (!newpart.match(hostnamePartPattern)) {
  505. var validParts = hostparts.slice(0, i);
  506. var notHost = hostparts.slice(i + 1);
  507. var bit = part.match(hostnamePartStart);
  508. if (bit) {
  509. validParts.push(bit[1]);
  510. notHost.unshift(bit[2]);
  511. }
  512. if (notHost.length) {
  513. rest = "/" + notHost.join(".") + rest;
  514. }
  515. this.hostname = validParts.join(".");
  516. break;
  517. }
  518. }
  519. }
  520. }
  521. if (this.hostname.length > hostnameMaxLen) {
  522. this.hostname = "";
  523. } else {
  524. this.hostname = this.hostname.toLowerCase();
  525. }
  526. if (!ipv6Hostname) {
  527. this.hostname = punycode.toASCII(this.hostname);
  528. }
  529. var p = this.port ? ":" + this.port : "";
  530. var h = this.hostname || "";
  531. this.host = h + p;
  532. this.href += this.host;
  533. if (ipv6Hostname) {
  534. this.hostname = this.hostname.substr(1, this.hostname.length - 2);
  535. if (rest[0] !== "/") {
  536. rest = "/" + rest;
  537. }
  538. }
  539. }
  540. if (!unsafeProtocol[lowerProto]) {
  541. for (var i = 0, l = autoEscape.length; i < l; i++) {
  542. var ae = autoEscape[i];
  543. if (rest.indexOf(ae) === -1)
  544. continue;
  545. var esc = encodeURIComponent(ae);
  546. if (esc === ae) {
  547. esc = escape(ae);
  548. }
  549. rest = rest.split(ae).join(esc);
  550. }
  551. }
  552. var hash = rest.indexOf("#");
  553. if (hash !== -1) {
  554. this.hash = rest.substr(hash);
  555. rest = rest.slice(0, hash);
  556. }
  557. var qm = rest.indexOf("?");
  558. if (qm !== -1) {
  559. this.search = rest.substr(qm);
  560. this.query = rest.substr(qm + 1);
  561. if (parseQueryString) {
  562. this.query = querystring.parse(this.query);
  563. }
  564. rest = rest.slice(0, qm);
  565. } else if (parseQueryString) {
  566. this.search = "";
  567. this.query = {};
  568. }
  569. if (rest)
  570. this.pathname = rest;
  571. if (slashedProtocol[lowerProto] && this.hostname && !this.pathname) {
  572. this.pathname = "/";
  573. }
  574. if (this.pathname || this.search) {
  575. var p = this.pathname || "";
  576. var s = this.search || "";
  577. this.path = p + s;
  578. }
  579. this.href = this.format();
  580. return this;
  581. };
  582. function urlFormat(obj) {
  583. if (util.isString(obj))
  584. obj = urlParse(obj);
  585. if (!(obj instanceof Url))
  586. return Url.prototype.format.call(obj);
  587. return obj.format();
  588. }
  589. Url.prototype.format = function() {
  590. var auth = this.auth || "";
  591. if (auth) {
  592. auth = encodeURIComponent(auth);
  593. auth = auth.replace(/%3A/i, ":");
  594. auth += "@";
  595. }
  596. var protocol = this.protocol || "", pathname = this.pathname || "", hash = this.hash || "", host = false, query = "";
  597. if (this.host) {
  598. host = auth + this.host;
  599. } else if (this.hostname) {
  600. host = auth + (this.hostname.indexOf(":") === -1 ? this.hostname : "[" + this.hostname + "]");
  601. if (this.port) {
  602. host += ":" + this.port;
  603. }
  604. }
  605. if (this.query && util.isObject(this.query) && Object.keys(this.query).length) {
  606. query = querystring.stringify(this.query);
  607. }
  608. var search = this.search || query && "?" + query || "";
  609. if (protocol && protocol.substr(-1) !== ":")
  610. protocol += ":";
  611. if (this.slashes || (!protocol || slashedProtocol[protocol]) && host !== false) {
  612. host = "//" + (host || "");
  613. if (pathname && pathname.charAt(0) !== "/")
  614. pathname = "/" + pathname;
  615. } else if (!host) {
  616. host = "";
  617. }
  618. if (hash && hash.charAt(0) !== "#")
  619. hash = "#" + hash;
  620. if (search && search.charAt(0) !== "?")
  621. search = "?" + search;
  622. pathname = pathname.replace(/[?#]/g, function(match) {
  623. return encodeURIComponent(match);
  624. });
  625. search = search.replace("#", "%23");
  626. return protocol + host + pathname + search + hash;
  627. };
  628. function urlResolve(source, relative) {
  629. return urlParse(source, false, true).resolve(relative);
  630. }
  631. Url.prototype.resolve = function(relative) {
  632. return this.resolveObject(urlParse(relative, false, true)).format();
  633. };
  634. function urlResolveObject(source, relative) {
  635. if (!source)
  636. return relative;
  637. return urlParse(source, false, true).resolveObject(relative);
  638. }
  639. Url.prototype.resolveObject = function(relative) {
  640. if (util.isString(relative)) {
  641. var rel = new Url();
  642. rel.parse(relative, false, true);
  643. relative = rel;
  644. }
  645. var result = new Url();
  646. var tkeys = Object.keys(this);
  647. for (var tk = 0; tk < tkeys.length; tk++) {
  648. var tkey = tkeys[tk];
  649. result[tkey] = this[tkey];
  650. }
  651. result.hash = relative.hash;
  652. if (relative.href === "") {
  653. result.href = result.format();
  654. return result;
  655. }
  656. if (relative.slashes && !relative.protocol) {
  657. var rkeys = Object.keys(relative);
  658. for (var rk = 0; rk < rkeys.length; rk++) {
  659. var rkey = rkeys[rk];
  660. if (rkey !== "protocol")
  661. result[rkey] = relative[rkey];
  662. }
  663. if (slashedProtocol[result.protocol] && result.hostname && !result.pathname) {
  664. result.path = result.pathname = "/";
  665. }
  666. result.href = result.format();
  667. return result;
  668. }
  669. if (relative.protocol && relative.protocol !== result.protocol) {
  670. if (!slashedProtocol[relative.protocol]) {
  671. var keys = Object.keys(relative);
  672. for (var v = 0; v < keys.length; v++) {
  673. var k = keys[v];
  674. result[k] = relative[k];
  675. }
  676. result.href = result.format();
  677. return result;
  678. }
  679. result.protocol = relative.protocol;
  680. if (!relative.host && !hostlessProtocol[relative.protocol]) {
  681. var relPath = (relative.pathname || "").split("/");
  682. while (relPath.length && !(relative.host = relPath.shift()))
  683. ;
  684. if (!relative.host)
  685. relative.host = "";
  686. if (!relative.hostname)
  687. relative.hostname = "";
  688. if (relPath[0] !== "")
  689. relPath.unshift("");
  690. if (relPath.length < 2)
  691. relPath.unshift("");
  692. result.pathname = relPath.join("/");
  693. } else {
  694. result.pathname = relative.pathname;
  695. }
  696. result.search = relative.search;
  697. result.query = relative.query;
  698. result.host = relative.host || "";
  699. result.auth = relative.auth;
  700. result.hostname = relative.hostname || relative.host;
  701. result.port = relative.port;
  702. if (result.pathname || result.search) {
  703. var p = result.pathname || "";
  704. var s = result.search || "";
  705. result.path = p + s;
  706. }
  707. result.slashes = result.slashes || relative.slashes;
  708. result.href = result.format();
  709. return result;
  710. }
  711. 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];
  712. if (psychotic) {
  713. result.hostname = "";
  714. result.port = null;
  715. if (result.host) {
  716. if (srcPath[0] === "")
  717. srcPath[0] = result.host;
  718. else
  719. srcPath.unshift(result.host);
  720. }
  721. result.host = "";
  722. if (relative.protocol) {
  723. relative.hostname = null;
  724. relative.port = null;
  725. if (relative.host) {
  726. if (relPath[0] === "")
  727. relPath[0] = relative.host;
  728. else
  729. relPath.unshift(relative.host);
  730. }
  731. relative.host = null;
  732. }
  733. mustEndAbs = mustEndAbs && (relPath[0] === "" || srcPath[0] === "");
  734. }
  735. if (isRelAbs) {
  736. result.host = relative.host || relative.host === "" ? relative.host : result.host;
  737. result.hostname = relative.hostname || relative.hostname === "" ? relative.hostname : result.hostname;
  738. result.search = relative.search;
  739. result.query = relative.query;
  740. srcPath = relPath;
  741. } else if (relPath.length) {
  742. if (!srcPath)
  743. srcPath = [];
  744. srcPath.pop();
  745. srcPath = srcPath.concat(relPath);
  746. result.search = relative.search;
  747. result.query = relative.query;
  748. } else if (!util.isNullOrUndefined(relative.search)) {
  749. if (psychotic) {
  750. result.hostname = result.host = srcPath.shift();
  751. var authInHost = result.host && result.host.indexOf("@") > 0 ? result.host.split("@") : false;
  752. if (authInHost) {
  753. result.auth = authInHost.shift();
  754. result.host = result.hostname = authInHost.shift();
  755. }
  756. }
  757. result.search = relative.search;
  758. result.query = relative.query;
  759. if (!util.isNull(result.pathname) || !util.isNull(result.search)) {
  760. result.path = (result.pathname ? result.pathname : "") + (result.search ? result.search : "");
  761. }
  762. result.href = result.format();
  763. return result;
  764. }
  765. if (!srcPath.length) {
  766. result.pathname = null;
  767. if (result.search) {
  768. result.path = "/" + result.search;
  769. } else {
  770. result.path = null;
  771. }
  772. result.href = result.format();
  773. return result;
  774. }
  775. var last = srcPath.slice(-1)[0];
  776. var hasTrailingSlash = (result.host || relative.host || srcPath.length > 1) && (last === "." || last === "..") || last === "";
  777. var up = 0;
  778. for (var i = srcPath.length; i >= 0; i--) {
  779. last = srcPath[i];
  780. if (last === ".") {
  781. srcPath.splice(i, 1);
  782. } else if (last === "..") {
  783. srcPath.splice(i, 1);
  784. up++;
  785. } else if (up) {
  786. srcPath.splice(i, 1);
  787. up--;
  788. }
  789. }
  790. if (!mustEndAbs && !removeAllDots) {
  791. for (; up--; up) {
  792. srcPath.unshift("..");
  793. }
  794. }
  795. if (mustEndAbs && srcPath[0] !== "" && (!srcPath[0] || srcPath[0].charAt(0) !== "/")) {
  796. srcPath.unshift("");
  797. }
  798. if (hasTrailingSlash && srcPath.join("/").substr(-1) !== "/") {
  799. srcPath.push("");
  800. }
  801. var isAbsolute = srcPath[0] === "" || srcPath[0] && srcPath[0].charAt(0) === "/";
  802. if (psychotic) {
  803. result.hostname = result.host = isAbsolute ? "" : srcPath.length ? srcPath.shift() : "";
  804. var authInHost = result.host && result.host.indexOf("@") > 0 ? result.host.split("@") : false;
  805. if (authInHost) {
  806. result.auth = authInHost.shift();
  807. result.host = result.hostname = authInHost.shift();
  808. }
  809. }
  810. mustEndAbs = mustEndAbs || result.host && srcPath.length;
  811. if (mustEndAbs && !isAbsolute) {
  812. srcPath.unshift("");
  813. }
  814. if (!srcPath.length) {
  815. result.pathname = null;
  816. result.path = null;
  817. } else {
  818. result.pathname = srcPath.join("/");
  819. }
  820. if (!util.isNull(result.pathname) || !util.isNull(result.search)) {
  821. result.path = (result.pathname ? result.pathname : "") + (result.search ? result.search : "");
  822. }
  823. result.auth = relative.auth || result.auth;
  824. result.slashes = result.slashes || relative.slashes;
  825. result.href = result.format();
  826. return result;
  827. };
  828. Url.prototype.parseHost = function() {
  829. var host = this.host;
  830. var port = portPattern.exec(host);
  831. if (port) {
  832. port = port[0];
  833. if (port !== ":") {
  834. this.port = port.substr(1);
  835. }
  836. host = host.substr(0, host.length - port.length);
  837. }
  838. if (host)
  839. this.hostname = host;
  840. };
  841. }
  842. });
  843. export default require_url();
  844. /*! https://mths.be/punycode v1.3.2 by @mathias */
  845. //# sourceMappingURL=url-DXYD2UK6.js.map