@andersbakken/fisk 4.0.0 → 4.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5633,7 +5633,7 @@ const http$3 = require$$2__default["default"];
5633
5633
  const net = require$$3__default["default"];
5634
5634
  const tls = require$$4__default$1["default"];
5635
5635
  const { randomBytes, createHash: createHash$1 } = require$$0__default$2["default"];
5636
- const { URL: URL$1 } = require$$0__default$3["default"];
5636
+ const { URL } = require$$0__default$3["default"];
5637
5637
 
5638
5638
  const PerMessageDeflate$1 = permessageDeflate;
5639
5639
  const Receiver = receiver;
@@ -6122,11 +6122,11 @@ function initAsClient(websocket, address, protocols, options) {
6122
6122
 
6123
6123
  let parsedUrl;
6124
6124
 
6125
- if (address instanceof URL$1) {
6125
+ if (address instanceof URL) {
6126
6126
  parsedUrl = address;
6127
6127
  websocket._url = address.href;
6128
6128
  } else {
6129
- parsedUrl = new URL$1(address);
6129
+ parsedUrl = new URL(address);
6130
6130
  websocket._url = address;
6131
6131
  }
6132
6132
 
@@ -6224,7 +6224,7 @@ function initAsClient(websocket, address, protocols, options) {
6224
6224
 
6225
6225
  req.abort();
6226
6226
 
6227
- const addr = new URL$1(location, address);
6227
+ const addr = new URL(location, address);
6228
6228
 
6229
6229
  initAsClient(websocket, addr, protocols, options);
6230
6230
  } else if (!websocket.emit('unexpected-response', req, res)) {
@@ -7735,10 +7735,10 @@ class ObjectCache extends EventEmitter__default["default"] {
7735
7735
  size: prettySize(this.size),
7736
7736
  purgeSize: prettySize(this.purgeSize)
7737
7737
  };
7738
- if (!query || !("object" in query)) {
7738
+ if (!query || !/<object>/.exec(query)) {
7739
7739
  delete ret.cache;
7740
7740
  }
7741
- if (!query || !("pending" in query)) {
7741
+ if (!query || !/<pending>/.exec(query)) {
7742
7742
  delete ret.pending;
7743
7743
  }
7744
7744
  return ret;
@@ -7834,6 +7834,750 @@ class Job extends EventEmitter__default["default"] {
7834
7834
  }
7835
7835
  }
7836
7836
 
7837
+ /**
7838
+ * Check if we're required to add a port number.
7839
+ *
7840
+ * @see https://url.spec.whatwg.org/#default-port
7841
+ * @param {Number|String} port Port number we need to check
7842
+ * @param {String} protocol Protocol we need to check against.
7843
+ * @returns {Boolean} Is it a default port for the given protocol
7844
+ * @api private
7845
+ */
7846
+ var requiresPort = function required(port, protocol) {
7847
+ protocol = protocol.split(':')[0];
7848
+ port = +port;
7849
+
7850
+ if (!port) return false;
7851
+
7852
+ switch (protocol) {
7853
+ case 'http':
7854
+ case 'ws':
7855
+ return port !== 80;
7856
+
7857
+ case 'https':
7858
+ case 'wss':
7859
+ return port !== 443;
7860
+
7861
+ case 'ftp':
7862
+ return port !== 21;
7863
+
7864
+ case 'gopher':
7865
+ return port !== 70;
7866
+
7867
+ case 'file':
7868
+ return false;
7869
+ }
7870
+
7871
+ return port !== 0;
7872
+ };
7873
+
7874
+ var querystringify$1 = {};
7875
+
7876
+ var has$4 = Object.prototype.hasOwnProperty
7877
+ , undef;
7878
+
7879
+ /**
7880
+ * Decode a URI encoded string.
7881
+ *
7882
+ * @param {String} input The URI encoded string.
7883
+ * @returns {String|Null} The decoded string.
7884
+ * @api private
7885
+ */
7886
+ function decode$3(input) {
7887
+ try {
7888
+ return decodeURIComponent(input.replace(/\+/g, ' '));
7889
+ } catch (e) {
7890
+ return null;
7891
+ }
7892
+ }
7893
+
7894
+ /**
7895
+ * Attempts to encode a given input.
7896
+ *
7897
+ * @param {String} input The string that needs to be encoded.
7898
+ * @returns {String|Null} The encoded string.
7899
+ * @api private
7900
+ */
7901
+ function encode$3(input) {
7902
+ try {
7903
+ return encodeURIComponent(input);
7904
+ } catch (e) {
7905
+ return null;
7906
+ }
7907
+ }
7908
+
7909
+ /**
7910
+ * Simple query string parser.
7911
+ *
7912
+ * @param {String} query The query string that needs to be parsed.
7913
+ * @returns {Object}
7914
+ * @api public
7915
+ */
7916
+ function querystring(query) {
7917
+ var parser = /([^=?#&]+)=?([^&]*)/g
7918
+ , result = {}
7919
+ , part;
7920
+
7921
+ while (part = parser.exec(query)) {
7922
+ var key = decode$3(part[1])
7923
+ , value = decode$3(part[2]);
7924
+
7925
+ //
7926
+ // Prevent overriding of existing properties. This ensures that build-in
7927
+ // methods like `toString` or __proto__ are not overriden by malicious
7928
+ // querystrings.
7929
+ //
7930
+ // In the case if failed decoding, we want to omit the key/value pairs
7931
+ // from the result.
7932
+ //
7933
+ if (key === null || value === null || key in result) continue;
7934
+ result[key] = value;
7935
+ }
7936
+
7937
+ return result;
7938
+ }
7939
+
7940
+ /**
7941
+ * Transform a query string to an object.
7942
+ *
7943
+ * @param {Object} obj Object that should be transformed.
7944
+ * @param {String} prefix Optional prefix.
7945
+ * @returns {String}
7946
+ * @api public
7947
+ */
7948
+ function querystringify(obj, prefix) {
7949
+ prefix = prefix || '';
7950
+
7951
+ var pairs = []
7952
+ , value
7953
+ , key;
7954
+
7955
+ //
7956
+ // Optionally prefix with a '?' if needed
7957
+ //
7958
+ if ('string' !== typeof prefix) prefix = '?';
7959
+
7960
+ for (key in obj) {
7961
+ if (has$4.call(obj, key)) {
7962
+ value = obj[key];
7963
+
7964
+ //
7965
+ // Edge cases where we actually want to encode the value to an empty
7966
+ // string instead of the stringified value.
7967
+ //
7968
+ if (!value && (value === null || value === undef || isNaN(value))) {
7969
+ value = '';
7970
+ }
7971
+
7972
+ key = encode$3(key);
7973
+ value = encode$3(value);
7974
+
7975
+ //
7976
+ // If we failed to encode the strings, we should bail out as we don't
7977
+ // want to add invalid strings to the query.
7978
+ //
7979
+ if (key === null || value === null) continue;
7980
+ pairs.push(key +'='+ value);
7981
+ }
7982
+ }
7983
+
7984
+ return pairs.length ? prefix + pairs.join('&') : '';
7985
+ }
7986
+
7987
+ //
7988
+ // Expose the module.
7989
+ //
7990
+ querystringify$1.stringify = querystringify;
7991
+ querystringify$1.parse = querystring;
7992
+
7993
+ var required = requiresPort
7994
+ , qs = querystringify$1
7995
+ , controlOrWhitespace = /^[\x00-\x20\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]+/
7996
+ , CRHTLF = /[\n\r\t]/g
7997
+ , slashes = /^[A-Za-z][A-Za-z0-9+-.]*:\/\//
7998
+ , port = /:\d+$/
7999
+ , protocolre = /^([a-z][a-z0-9.+-]*:)?(\/\/)?([\\/]+)?([\S\s]*)/i
8000
+ , windowsDriveLetter = /^[a-zA-Z]:/;
8001
+
8002
+ /**
8003
+ * Remove control characters and whitespace from the beginning of a string.
8004
+ *
8005
+ * @param {Object|String} str String to trim.
8006
+ * @returns {String} A new string representing `str` stripped of control
8007
+ * characters and whitespace from its beginning.
8008
+ * @public
8009
+ */
8010
+ function trimLeft(str) {
8011
+ return (str ? str : '').toString().replace(controlOrWhitespace, '');
8012
+ }
8013
+
8014
+ /**
8015
+ * These are the parse rules for the URL parser, it informs the parser
8016
+ * about:
8017
+ *
8018
+ * 0. The char it Needs to parse, if it's a string it should be done using
8019
+ * indexOf, RegExp using exec and NaN means set as current value.
8020
+ * 1. The property we should set when parsing this value.
8021
+ * 2. Indication if it's backwards or forward parsing, when set as number it's
8022
+ * the value of extra chars that should be split off.
8023
+ * 3. Inherit from location if non existing in the parser.
8024
+ * 4. `toLowerCase` the resulting value.
8025
+ */
8026
+ var rules = [
8027
+ ['#', 'hash'], // Extract from the back.
8028
+ ['?', 'query'], // Extract from the back.
8029
+ function sanitize(address, url) { // Sanitize what is left of the address
8030
+ return isSpecial(url.protocol) ? address.replace(/\\/g, '/') : address;
8031
+ },
8032
+ ['/', 'pathname'], // Extract from the back.
8033
+ ['@', 'auth', 1], // Extract from the front.
8034
+ [NaN, 'host', undefined, 1, 1], // Set left over value.
8035
+ [/:(\d*)$/, 'port', undefined, 1], // RegExp the back.
8036
+ [NaN, 'hostname', undefined, 1, 1] // Set left over.
8037
+ ];
8038
+
8039
+ /**
8040
+ * These properties should not be copied or inherited from. This is only needed
8041
+ * for all non blob URL's as a blob URL does not include a hash, only the
8042
+ * origin.
8043
+ *
8044
+ * @type {Object}
8045
+ * @private
8046
+ */
8047
+ var ignore = { hash: 1, query: 1 };
8048
+
8049
+ /**
8050
+ * The location object differs when your code is loaded through a normal page,
8051
+ * Worker or through a worker using a blob. And with the blobble begins the
8052
+ * trouble as the location object will contain the URL of the blob, not the
8053
+ * location of the page where our code is loaded in. The actual origin is
8054
+ * encoded in the `pathname` so we can thankfully generate a good "default"
8055
+ * location from it so we can generate proper relative URL's again.
8056
+ *
8057
+ * @param {Object|String} loc Optional default location object.
8058
+ * @returns {Object} lolcation object.
8059
+ * @public
8060
+ */
8061
+ function lolcation(loc) {
8062
+ var globalVar;
8063
+
8064
+ if (typeof window !== 'undefined') globalVar = window;
8065
+ else if (typeof commonjsGlobal !== 'undefined') globalVar = commonjsGlobal;
8066
+ else if (typeof self !== 'undefined') globalVar = self;
8067
+ else globalVar = {};
8068
+
8069
+ var location = globalVar.location || {};
8070
+ loc = loc || location;
8071
+
8072
+ var finaldestination = {}
8073
+ , type = typeof loc
8074
+ , key;
8075
+
8076
+ if ('blob:' === loc.protocol) {
8077
+ finaldestination = new Url$1(unescape(loc.pathname), {});
8078
+ } else if ('string' === type) {
8079
+ finaldestination = new Url$1(loc, {});
8080
+ for (key in ignore) delete finaldestination[key];
8081
+ } else if ('object' === type) {
8082
+ for (key in loc) {
8083
+ if (key in ignore) continue;
8084
+ finaldestination[key] = loc[key];
8085
+ }
8086
+
8087
+ if (finaldestination.slashes === undefined) {
8088
+ finaldestination.slashes = slashes.test(loc.href);
8089
+ }
8090
+ }
8091
+
8092
+ return finaldestination;
8093
+ }
8094
+
8095
+ /**
8096
+ * Check whether a protocol scheme is special.
8097
+ *
8098
+ * @param {String} The protocol scheme of the URL
8099
+ * @return {Boolean} `true` if the protocol scheme is special, else `false`
8100
+ * @private
8101
+ */
8102
+ function isSpecial(scheme) {
8103
+ return (
8104
+ scheme === 'file:' ||
8105
+ scheme === 'ftp:' ||
8106
+ scheme === 'http:' ||
8107
+ scheme === 'https:' ||
8108
+ scheme === 'ws:' ||
8109
+ scheme === 'wss:'
8110
+ );
8111
+ }
8112
+
8113
+ /**
8114
+ * @typedef ProtocolExtract
8115
+ * @type Object
8116
+ * @property {String} protocol Protocol matched in the URL, in lowercase.
8117
+ * @property {Boolean} slashes `true` if protocol is followed by "//", else `false`.
8118
+ * @property {String} rest Rest of the URL that is not part of the protocol.
8119
+ */
8120
+
8121
+ /**
8122
+ * Extract protocol information from a URL with/without double slash ("//").
8123
+ *
8124
+ * @param {String} address URL we want to extract from.
8125
+ * @param {Object} location
8126
+ * @return {ProtocolExtract} Extracted information.
8127
+ * @private
8128
+ */
8129
+ function extractProtocol(address, location) {
8130
+ address = trimLeft(address);
8131
+ address = address.replace(CRHTLF, '');
8132
+ location = location || {};
8133
+
8134
+ var match = protocolre.exec(address);
8135
+ var protocol = match[1] ? match[1].toLowerCase() : '';
8136
+ var forwardSlashes = !!match[2];
8137
+ var otherSlashes = !!match[3];
8138
+ var slashesCount = 0;
8139
+ var rest;
8140
+
8141
+ if (forwardSlashes) {
8142
+ if (otherSlashes) {
8143
+ rest = match[2] + match[3] + match[4];
8144
+ slashesCount = match[2].length + match[3].length;
8145
+ } else {
8146
+ rest = match[2] + match[4];
8147
+ slashesCount = match[2].length;
8148
+ }
8149
+ } else {
8150
+ if (otherSlashes) {
8151
+ rest = match[3] + match[4];
8152
+ slashesCount = match[3].length;
8153
+ } else {
8154
+ rest = match[4];
8155
+ }
8156
+ }
8157
+
8158
+ if (protocol === 'file:') {
8159
+ if (slashesCount >= 2) {
8160
+ rest = rest.slice(2);
8161
+ }
8162
+ } else if (isSpecial(protocol)) {
8163
+ rest = match[4];
8164
+ } else if (protocol) {
8165
+ if (forwardSlashes) {
8166
+ rest = rest.slice(2);
8167
+ }
8168
+ } else if (slashesCount >= 2 && isSpecial(location.protocol)) {
8169
+ rest = match[4];
8170
+ }
8171
+
8172
+ return {
8173
+ protocol: protocol,
8174
+ slashes: forwardSlashes || isSpecial(protocol),
8175
+ slashesCount: slashesCount,
8176
+ rest: rest
8177
+ };
8178
+ }
8179
+
8180
+ /**
8181
+ * Resolve a relative URL pathname against a base URL pathname.
8182
+ *
8183
+ * @param {String} relative Pathname of the relative URL.
8184
+ * @param {String} base Pathname of the base URL.
8185
+ * @return {String} Resolved pathname.
8186
+ * @private
8187
+ */
8188
+ function resolve$4(relative, base) {
8189
+ if (relative === '') return base;
8190
+
8191
+ var path = (base || '/').split('/').slice(0, -1).concat(relative.split('/'))
8192
+ , i = path.length
8193
+ , last = path[i - 1]
8194
+ , unshift = false
8195
+ , up = 0;
8196
+
8197
+ while (i--) {
8198
+ if (path[i] === '.') {
8199
+ path.splice(i, 1);
8200
+ } else if (path[i] === '..') {
8201
+ path.splice(i, 1);
8202
+ up++;
8203
+ } else if (up) {
8204
+ if (i === 0) unshift = true;
8205
+ path.splice(i, 1);
8206
+ up--;
8207
+ }
8208
+ }
8209
+
8210
+ if (unshift) path.unshift('');
8211
+ if (last === '.' || last === '..') path.push('');
8212
+
8213
+ return path.join('/');
8214
+ }
8215
+
8216
+ /**
8217
+ * The actual URL instance. Instead of returning an object we've opted-in to
8218
+ * create an actual constructor as it's much more memory efficient and
8219
+ * faster and it pleases my OCD.
8220
+ *
8221
+ * It is worth noting that we should not use `URL` as class name to prevent
8222
+ * clashes with the global URL instance that got introduced in browsers.
8223
+ *
8224
+ * @constructor
8225
+ * @param {String} address URL we want to parse.
8226
+ * @param {Object|String} [location] Location defaults for relative paths.
8227
+ * @param {Boolean|Function} [parser] Parser for the query string.
8228
+ * @private
8229
+ */
8230
+ function Url$1(address, location, parser) {
8231
+ address = trimLeft(address);
8232
+ address = address.replace(CRHTLF, '');
8233
+
8234
+ if (!(this instanceof Url$1)) {
8235
+ return new Url$1(address, location, parser);
8236
+ }
8237
+
8238
+ var relative, extracted, parse, instruction, index, key
8239
+ , instructions = rules.slice()
8240
+ , type = typeof location
8241
+ , url = this
8242
+ , i = 0;
8243
+
8244
+ //
8245
+ // The following if statements allows this module two have compatibility with
8246
+ // 2 different API:
8247
+ //
8248
+ // 1. Node.js's `url.parse` api which accepts a URL, boolean as arguments
8249
+ // where the boolean indicates that the query string should also be parsed.
8250
+ //
8251
+ // 2. The `URL` interface of the browser which accepts a URL, object as
8252
+ // arguments. The supplied object will be used as default values / fall-back
8253
+ // for relative paths.
8254
+ //
8255
+ if ('object' !== type && 'string' !== type) {
8256
+ parser = location;
8257
+ location = null;
8258
+ }
8259
+
8260
+ if (parser && 'function' !== typeof parser) parser = qs.parse;
8261
+
8262
+ location = lolcation(location);
8263
+
8264
+ //
8265
+ // Extract protocol information before running the instructions.
8266
+ //
8267
+ extracted = extractProtocol(address || '', location);
8268
+ relative = !extracted.protocol && !extracted.slashes;
8269
+ url.slashes = extracted.slashes || relative && location.slashes;
8270
+ url.protocol = extracted.protocol || location.protocol || '';
8271
+ address = extracted.rest;
8272
+
8273
+ //
8274
+ // When the authority component is absent the URL starts with a path
8275
+ // component.
8276
+ //
8277
+ if (
8278
+ extracted.protocol === 'file:' && (
8279
+ extracted.slashesCount !== 2 || windowsDriveLetter.test(address)) ||
8280
+ (!extracted.slashes &&
8281
+ (extracted.protocol ||
8282
+ extracted.slashesCount < 2 ||
8283
+ !isSpecial(url.protocol)))
8284
+ ) {
8285
+ instructions[3] = [/(.*)/, 'pathname'];
8286
+ }
8287
+
8288
+ for (; i < instructions.length; i++) {
8289
+ instruction = instructions[i];
8290
+
8291
+ if (typeof instruction === 'function') {
8292
+ address = instruction(address, url);
8293
+ continue;
8294
+ }
8295
+
8296
+ parse = instruction[0];
8297
+ key = instruction[1];
8298
+
8299
+ if (parse !== parse) {
8300
+ url[key] = address;
8301
+ } else if ('string' === typeof parse) {
8302
+ index = parse === '@'
8303
+ ? address.lastIndexOf(parse)
8304
+ : address.indexOf(parse);
8305
+
8306
+ if (~index) {
8307
+ if ('number' === typeof instruction[2]) {
8308
+ url[key] = address.slice(0, index);
8309
+ address = address.slice(index + instruction[2]);
8310
+ } else {
8311
+ url[key] = address.slice(index);
8312
+ address = address.slice(0, index);
8313
+ }
8314
+ }
8315
+ } else if ((index = parse.exec(address))) {
8316
+ url[key] = index[1];
8317
+ address = address.slice(0, index.index);
8318
+ }
8319
+
8320
+ url[key] = url[key] || (
8321
+ relative && instruction[3] ? location[key] || '' : ''
8322
+ );
8323
+
8324
+ //
8325
+ // Hostname, host and protocol should be lowercased so they can be used to
8326
+ // create a proper `origin`.
8327
+ //
8328
+ if (instruction[4]) url[key] = url[key].toLowerCase();
8329
+ }
8330
+
8331
+ //
8332
+ // Also parse the supplied query string in to an object. If we're supplied
8333
+ // with a custom parser as function use that instead of the default build-in
8334
+ // parser.
8335
+ //
8336
+ if (parser) url.query = parser(url.query);
8337
+
8338
+ //
8339
+ // If the URL is relative, resolve the pathname against the base URL.
8340
+ //
8341
+ if (
8342
+ relative
8343
+ && location.slashes
8344
+ && url.pathname.charAt(0) !== '/'
8345
+ && (url.pathname !== '' || location.pathname !== '')
8346
+ ) {
8347
+ url.pathname = resolve$4(url.pathname, location.pathname);
8348
+ }
8349
+
8350
+ //
8351
+ // Default to a / for pathname if none exists. This normalizes the URL
8352
+ // to always have a /
8353
+ //
8354
+ if (url.pathname.charAt(0) !== '/' && isSpecial(url.protocol)) {
8355
+ url.pathname = '/' + url.pathname;
8356
+ }
8357
+
8358
+ //
8359
+ // We should not add port numbers if they are already the default port number
8360
+ // for a given protocol. As the host also contains the port number we're going
8361
+ // override it with the hostname which contains no port number.
8362
+ //
8363
+ if (!required(url.port, url.protocol)) {
8364
+ url.host = url.hostname;
8365
+ url.port = '';
8366
+ }
8367
+
8368
+ //
8369
+ // Parse down the `auth` for the username and password.
8370
+ //
8371
+ url.username = url.password = '';
8372
+
8373
+ if (url.auth) {
8374
+ index = url.auth.indexOf(':');
8375
+
8376
+ if (~index) {
8377
+ url.username = url.auth.slice(0, index);
8378
+ url.username = encodeURIComponent(decodeURIComponent(url.username));
8379
+
8380
+ url.password = url.auth.slice(index + 1);
8381
+ url.password = encodeURIComponent(decodeURIComponent(url.password));
8382
+ } else {
8383
+ url.username = encodeURIComponent(decodeURIComponent(url.auth));
8384
+ }
8385
+
8386
+ url.auth = url.password ? url.username +':'+ url.password : url.username;
8387
+ }
8388
+
8389
+ url.origin = url.protocol !== 'file:' && isSpecial(url.protocol) && url.host
8390
+ ? url.protocol +'//'+ url.host
8391
+ : 'null';
8392
+
8393
+ //
8394
+ // The href is just the compiled result.
8395
+ //
8396
+ url.href = url.toString();
8397
+ }
8398
+
8399
+ /**
8400
+ * This is convenience method for changing properties in the URL instance to
8401
+ * insure that they all propagate correctly.
8402
+ *
8403
+ * @param {String} part Property we need to adjust.
8404
+ * @param {Mixed} value The newly assigned value.
8405
+ * @param {Boolean|Function} fn When setting the query, it will be the function
8406
+ * used to parse the query.
8407
+ * When setting the protocol, double slash will be
8408
+ * removed from the final url if it is true.
8409
+ * @returns {URL} URL instance for chaining.
8410
+ * @public
8411
+ */
8412
+ function set(part, value, fn) {
8413
+ var url = this;
8414
+
8415
+ switch (part) {
8416
+ case 'query':
8417
+ if ('string' === typeof value && value.length) {
8418
+ value = (fn || qs.parse)(value);
8419
+ }
8420
+
8421
+ url[part] = value;
8422
+ break;
8423
+
8424
+ case 'port':
8425
+ url[part] = value;
8426
+
8427
+ if (!required(value, url.protocol)) {
8428
+ url.host = url.hostname;
8429
+ url[part] = '';
8430
+ } else if (value) {
8431
+ url.host = url.hostname +':'+ value;
8432
+ }
8433
+
8434
+ break;
8435
+
8436
+ case 'hostname':
8437
+ url[part] = value;
8438
+
8439
+ if (url.port) value += ':'+ url.port;
8440
+ url.host = value;
8441
+ break;
8442
+
8443
+ case 'host':
8444
+ url[part] = value;
8445
+
8446
+ if (port.test(value)) {
8447
+ value = value.split(':');
8448
+ url.port = value.pop();
8449
+ url.hostname = value.join(':');
8450
+ } else {
8451
+ url.hostname = value;
8452
+ url.port = '';
8453
+ }
8454
+
8455
+ break;
8456
+
8457
+ case 'protocol':
8458
+ url.protocol = value.toLowerCase();
8459
+ url.slashes = !fn;
8460
+ break;
8461
+
8462
+ case 'pathname':
8463
+ case 'hash':
8464
+ if (value) {
8465
+ var char = part === 'pathname' ? '/' : '#';
8466
+ url[part] = value.charAt(0) !== char ? char + value : value;
8467
+ } else {
8468
+ url[part] = value;
8469
+ }
8470
+ break;
8471
+
8472
+ case 'username':
8473
+ case 'password':
8474
+ url[part] = encodeURIComponent(value);
8475
+ break;
8476
+
8477
+ case 'auth':
8478
+ var index = value.indexOf(':');
8479
+
8480
+ if (~index) {
8481
+ url.username = value.slice(0, index);
8482
+ url.username = encodeURIComponent(decodeURIComponent(url.username));
8483
+
8484
+ url.password = value.slice(index + 1);
8485
+ url.password = encodeURIComponent(decodeURIComponent(url.password));
8486
+ } else {
8487
+ url.username = encodeURIComponent(decodeURIComponent(value));
8488
+ }
8489
+ }
8490
+
8491
+ for (var i = 0; i < rules.length; i++) {
8492
+ var ins = rules[i];
8493
+
8494
+ if (ins[4]) url[ins[1]] = url[ins[1]].toLowerCase();
8495
+ }
8496
+
8497
+ url.auth = url.password ? url.username +':'+ url.password : url.username;
8498
+
8499
+ url.origin = url.protocol !== 'file:' && isSpecial(url.protocol) && url.host
8500
+ ? url.protocol +'//'+ url.host
8501
+ : 'null';
8502
+
8503
+ url.href = url.toString();
8504
+
8505
+ return url;
8506
+ }
8507
+
8508
+ /**
8509
+ * Transform the properties back in to a valid and full URL string.
8510
+ *
8511
+ * @param {Function} stringify Optional query stringify function.
8512
+ * @returns {String} Compiled version of the URL.
8513
+ * @public
8514
+ */
8515
+ function toString$4(stringify) {
8516
+ if (!stringify || 'function' !== typeof stringify) stringify = qs.stringify;
8517
+
8518
+ var query
8519
+ , url = this
8520
+ , host = url.host
8521
+ , protocol = url.protocol;
8522
+
8523
+ if (protocol && protocol.charAt(protocol.length - 1) !== ':') protocol += ':';
8524
+
8525
+ var result =
8526
+ protocol +
8527
+ ((url.protocol && url.slashes) || isSpecial(url.protocol) ? '//' : '');
8528
+
8529
+ if (url.username) {
8530
+ result += url.username;
8531
+ if (url.password) result += ':'+ url.password;
8532
+ result += '@';
8533
+ } else if (url.password) {
8534
+ result += ':'+ url.password;
8535
+ result += '@';
8536
+ } else if (
8537
+ url.protocol !== 'file:' &&
8538
+ isSpecial(url.protocol) &&
8539
+ !host &&
8540
+ url.pathname !== '/'
8541
+ ) {
8542
+ //
8543
+ // Add back the empty userinfo, otherwise the original invalid URL
8544
+ // might be transformed into a valid one with `url.pathname` as host.
8545
+ //
8546
+ result += '@';
8547
+ }
8548
+
8549
+ //
8550
+ // Trailing colon is removed from `url.host` when it is parsed. If it still
8551
+ // ends with a colon, then add back the trailing colon that was removed. This
8552
+ // prevents an invalid URL from being transformed into a valid one.
8553
+ //
8554
+ if (host[host.length - 1] === ':' || (port.test(url.hostname) && !url.port)) {
8555
+ host += ':';
8556
+ }
8557
+
8558
+ result += host + url.pathname;
8559
+
8560
+ query = 'object' === typeof url.query ? stringify(url.query) : url.query;
8561
+ if (query) result += '?' !== query.charAt(0) ? '?'+ query : query;
8562
+
8563
+ if (url.hash) result += url.hash;
8564
+
8565
+ return result;
8566
+ }
8567
+
8568
+ Url$1.prototype = { set: set, toString: toString$4 };
8569
+
8570
+ //
8571
+ // Expose the URL parser and some additional properties that might be useful for
8572
+ // others or testing.
8573
+ //
8574
+ Url$1.extractProtocol = extractProtocol;
8575
+ Url$1.location = lolcation;
8576
+ Url$1.trimLeft = trimLeft;
8577
+ Url$1.qs = qs;
8578
+
8579
+ var urlParse = Url$1;
8580
+
7837
8581
  var expressExports$1 = {};
7838
8582
  var express$2 = {
7839
8583
  get exports(){ return expressExports$1; },
@@ -50275,7 +51019,7 @@ class Server extends EventEmitter__default["default"] {
50275
51019
  if (ip.substring(0, 7) === "::ffff:") {
50276
51020
  ip = ip.substring(7);
50277
51021
  }
50278
- const url = new URL(req.url || "", this.baseUrl);
51022
+ const url = new urlParse(req.url || "", this.baseUrl);
50279
51023
  switch (url.pathname) {
50280
51024
  case "/compile": {
50281
51025
  const hash = String(req.headers["x-fisk-environments"]);
@@ -54911,10 +55655,10 @@ server.on("listen", (app) => {
54911
55655
  res.sendStatus(404);
54912
55656
  return;
54913
55657
  }
54914
- const parsed = new URL(req.url || "", server.baseUrl);
55658
+ const parsed = new urlParse(req.url || "", server.baseUrl);
54915
55659
  const urlPath = parsed.pathname.substring(13);
54916
55660
  if (urlPath === "info") {
54917
- res.send(JSON.stringify(objectCache.info(parsed.searchParams), null, 4));
55661
+ res.send(JSON.stringify(objectCache.info(parsed.query), null, 4));
54918
55662
  return;
54919
55663
  }
54920
55664
  const data = objectCache.get(urlPath, true);