@kubohiroya/turbowarp-cloudflare-worker 0.8.1 → 0.9.1

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.
@@ -7088,8 +7088,10 @@ var require_formats = /* @__PURE__ */ __commonJSMin(((exports) => {
7088
7088
  }
7089
7089
  exports.fullFormats = {
7090
7090
  date: fmtDef(date, compareDate),
7091
- time: fmtDef(time, compareTime),
7092
- "date-time": fmtDef(date_time, compareDateTime),
7091
+ time: fmtDef(getTime(true), compareTime),
7092
+ "date-time": fmtDef(getDateTime(true), compareDateTime),
7093
+ "iso-time": fmtDef(getTime(), compareIsoTime),
7094
+ "iso-date-time": fmtDef(getDateTime(), compareIsoDateTime),
7093
7095
  duration: /^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,
7094
7096
  uri,
7095
7097
  "uri-reference": /^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,
@@ -7097,7 +7099,7 @@ var require_formats = /* @__PURE__ */ __commonJSMin(((exports) => {
7097
7099
  url: /^(?:https?|ftp):\/\/(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)(?:\.(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu,
7098
7100
  email: /^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i,
7099
7101
  hostname: /^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i,
7100
- ipv4: /^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,
7102
+ ipv4: /^(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)$/,
7101
7103
  ipv6: /^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))$/i,
7102
7104
  regex,
7103
7105
  uuid: /^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,
@@ -7127,8 +7129,10 @@ var require_formats = /* @__PURE__ */ __commonJSMin(((exports) => {
7127
7129
  exports.fastFormats = {
7128
7130
  ...exports.fullFormats,
7129
7131
  date: fmtDef(/^\d\d\d\d-[0-1]\d-[0-3]\d$/, compareDate),
7130
- time: fmtDef(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i, compareTime),
7131
- "date-time": fmtDef(/^\d\d\d\d-[0-1]\d-[0-3]\d[t\s](?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i, compareDateTime),
7132
+ time: fmtDef(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i, compareTime),
7133
+ "date-time": fmtDef(/^\d\d\d\d-[0-1]\d-[0-3]\dt(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i, compareDateTime),
7134
+ "iso-time": fmtDef(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i, compareIsoTime),
7135
+ "iso-date-time": fmtDef(/^\d\d\d\d-[0-1]\d-[0-3]\d[t\s](?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i, compareIsoDateTime),
7132
7136
  uri: /^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/)?[^\s]*$/i,
7133
7137
  "uri-reference": /^(?:(?:[a-z][a-z0-9+\-.]*:)?\/?\/)?(?:[^\\\s#][^\s#]*)?(?:#[^\\\s]*)?$/i,
7134
7138
  email: /^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/i
@@ -7167,33 +7171,59 @@ var require_formats = /* @__PURE__ */ __commonJSMin(((exports) => {
7167
7171
  if (d1 < d2) return -1;
7168
7172
  return 0;
7169
7173
  }
7170
- var TIME = /^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d(?::?\d\d)?)?$/i;
7171
- function time(str, withTimeZone) {
7172
- const matches = TIME.exec(str);
7173
- if (!matches) return false;
7174
- const hour = +matches[1];
7175
- const minute = +matches[2];
7176
- const second = +matches[3];
7177
- const timeZone = matches[5];
7178
- return (hour <= 23 && minute <= 59 && second <= 59 || hour === 23 && minute === 59 && second === 60) && (!withTimeZone || timeZone !== "");
7174
+ var TIME = /^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;
7175
+ function getTime(strictTimeZone) {
7176
+ return function time(str) {
7177
+ const matches = TIME.exec(str);
7178
+ if (!matches) return false;
7179
+ const hr = +matches[1];
7180
+ const min = +matches[2];
7181
+ const sec = +matches[3];
7182
+ const tz = matches[4];
7183
+ const tzSign = matches[5] === "-" ? -1 : 1;
7184
+ const tzH = +(matches[6] || 0);
7185
+ const tzM = +(matches[7] || 0);
7186
+ if (tzH > 23 || tzM > 59 || strictTimeZone && !tz) return false;
7187
+ if (hr <= 23 && min <= 59 && sec < 60) return true;
7188
+ const utcMin = min - tzM * tzSign;
7189
+ const utcHr = hr - tzH * tzSign - (utcMin < 0 ? 1 : 0);
7190
+ return (utcHr === 23 || utcHr === -1) && (utcMin === 59 || utcMin === -1) && sec < 61;
7191
+ };
7179
7192
  }
7180
- function compareTime(t1, t2) {
7193
+ function compareTime(s1, s2) {
7194
+ if (!(s1 && s2)) return void 0;
7195
+ const t1 = (/* @__PURE__ */ new Date("2020-01-01T" + s1)).valueOf();
7196
+ const t2 = (/* @__PURE__ */ new Date("2020-01-01T" + s2)).valueOf();
7197
+ if (!(t1 && t2)) return void 0;
7198
+ return t1 - t2;
7199
+ }
7200
+ function compareIsoTime(t1, t2) {
7181
7201
  if (!(t1 && t2)) return void 0;
7182
7202
  const a1 = TIME.exec(t1);
7183
7203
  const a2 = TIME.exec(t2);
7184
7204
  if (!(a1 && a2)) return void 0;
7185
- t1 = a1[1] + a1[2] + a1[3] + (a1[4] || "");
7186
- t2 = a2[1] + a2[2] + a2[3] + (a2[4] || "");
7205
+ t1 = a1[1] + a1[2] + a1[3];
7206
+ t2 = a2[1] + a2[2] + a2[3];
7187
7207
  if (t1 > t2) return 1;
7188
7208
  if (t1 < t2) return -1;
7189
7209
  return 0;
7190
7210
  }
7191
7211
  var DATE_TIME_SEPARATOR = /t|\s/i;
7192
- function date_time(str) {
7193
- const dateTime = str.split(DATE_TIME_SEPARATOR);
7194
- return dateTime.length === 2 && date(dateTime[0]) && time(dateTime[1], true);
7212
+ function getDateTime(strictTimeZone) {
7213
+ const time = getTime(strictTimeZone);
7214
+ return function date_time(str) {
7215
+ const dateTime = str.split(DATE_TIME_SEPARATOR);
7216
+ return dateTime.length === 2 && date(dateTime[0]) && time(dateTime[1]);
7217
+ };
7195
7218
  }
7196
7219
  function compareDateTime(dt1, dt2) {
7220
+ if (!(dt1 && dt2)) return void 0;
7221
+ const d1 = new Date(dt1).valueOf();
7222
+ const d2 = new Date(dt2).valueOf();
7223
+ if (!(d1 && d2)) return void 0;
7224
+ return d1 - d2;
7225
+ }
7226
+ function compareIsoDateTime(dt1, dt2) {
7197
7227
  if (!(dt1 && dt2)) return void 0;
7198
7228
  const [d1, t1] = dt1.split(DATE_TIME_SEPARATOR);
7199
7229
  const [d2, t2] = dt2.split(DATE_TIME_SEPARATOR);
@@ -7267,8 +7297,8 @@ var require_limit = /* @__PURE__ */ __commonJSMin(((exports) => {
7267
7297
  schemaType: "string",
7268
7298
  $data: true,
7269
7299
  error: {
7270
- message: ({ keyword, schemaCode }) => codegen_1.str`should be ${KWDs[keyword].okStr} ${schemaCode}`,
7271
- params: ({ keyword, schemaCode }) => codegen_1._`{comparison: ${KWDs[keyword].okStr}, limit: ${schemaCode}}`
7300
+ message: ({ keyword, schemaCode }) => (0, codegen_1.str)`should be ${KWDs[keyword].okStr} ${schemaCode}`,
7301
+ params: ({ keyword, schemaCode }) => (0, codegen_1._)`{comparison: ${KWDs[keyword].okStr}, limit: ${schemaCode}}`
7272
7302
  },
7273
7303
  code(cxt) {
7274
7304
  const { gen, data, schemaCode, keyword, it } = cxt;
@@ -7282,8 +7312,8 @@ var require_limit = /* @__PURE__ */ __commonJSMin(((exports) => {
7282
7312
  ref: self.formats,
7283
7313
  code: opts.code.formats
7284
7314
  });
7285
- const fmt = gen.const("fmt", codegen_1._`${fmts}[${fCxt.schemaCode}]`);
7286
- cxt.fail$data(codegen_1.or(codegen_1._`typeof ${fmt} != "object"`, codegen_1._`${fmt} instanceof RegExp`, codegen_1._`typeof ${fmt}.compare != "function"`, compareCode(fmt)));
7315
+ const fmt = gen.const("fmt", (0, codegen_1._)`${fmts}[${fCxt.schemaCode}]`);
7316
+ cxt.fail$data((0, codegen_1.or)((0, codegen_1._)`typeof ${fmt} != "object"`, (0, codegen_1._)`${fmt} instanceof RegExp`, (0, codegen_1._)`typeof ${fmt}.compare != "function"`, compareCode(fmt)));
7287
7317
  }
7288
7318
  function validateFormat() {
7289
7319
  const format = fCxt.schema;
@@ -7293,12 +7323,12 @@ var require_limit = /* @__PURE__ */ __commonJSMin(((exports) => {
7293
7323
  const fmt = gen.scopeValue("formats", {
7294
7324
  key: format,
7295
7325
  ref: fmtDef,
7296
- code: opts.code.formats ? codegen_1._`${opts.code.formats}${codegen_1.getProperty(format)}` : void 0
7326
+ code: opts.code.formats ? (0, codegen_1._)`${opts.code.formats}${(0, codegen_1.getProperty)(format)}` : void 0
7297
7327
  });
7298
7328
  cxt.fail$data(compareCode(fmt));
7299
7329
  }
7300
7330
  function compareCode(fmt) {
7301
- return codegen_1._`${fmt}.compare(${data}, ${schemaCode}) ${KWDs[keyword].fail} 0`;
7331
+ return (0, codegen_1._)`${fmt}.compare(${data}, ${schemaCode}) ${KWDs[keyword].fail} 0`;
7302
7332
  }
7303
7333
  },
7304
7334
  dependencies: ["format"]
@@ -7323,7 +7353,7 @@ var require_dist = /* @__PURE__ */ __commonJSMin(((exports, module) => {
7323
7353
  }
7324
7354
  const [formats, exportName] = opts.mode === "fast" ? [formats_1.fastFormats, fastName] : [formats_1.fullFormats, fullName];
7325
7355
  addFormats(ajv, opts.formats || formats_1.formatNames, formats, exportName);
7326
- if (opts.keywords) limit_1.default(ajv);
7356
+ if (opts.keywords) (0, limit_1.default)(ajv);
7327
7357
  return ajv;
7328
7358
  };
7329
7359
  formatsPlugin.get = (name, mode = "full") => {
@@ -7334,7 +7364,7 @@ var require_dist = /* @__PURE__ */ __commonJSMin(((exports, module) => {
7334
7364
  function addFormats(ajv, list, fs, exportName) {
7335
7365
  var _a;
7336
7366
  var _b;
7337
- (_a = (_b = ajv.opts.code).formats) !== null && _a !== void 0 || (_b.formats = codegen_1._`require("ajv-formats/dist/formats").${exportName}`);
7367
+ (_a = (_b = ajv.opts.code).formats) !== null && _a !== void 0 || (_b.formats = (0, codegen_1._)`require("ajv-formats/dist/formats").${exportName}`);
7338
7368
  for (const f of list) ajv.addFormat(f, fs[f]);
7339
7369
  }
7340
7370
  module.exports = exports = formatsPlugin;
@@ -7358,16 +7388,10 @@ var require_utils = /* @__PURE__ */ __commonJSMin(((exports, module) => {
7358
7388
  var isQueryFragmentCharacter = RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:@/?]$/u);
7359
7389
  /** @type {(value: string) => boolean} */
7360
7390
  var isUserinfoCharacter = RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:]$/u);
7361
- var BYTE_HEX = new Array(256);
7362
- {
7363
- const HEX_DIGITS = "0123456789ABCDEF";
7364
- for (let i = 0; i < 256; i++) BYTE_HEX[i] = "%" + HEX_DIGITS[i >> 4] + HEX_DIGITS[i & 15];
7365
- }
7366
- function percentEncodeNonAscii(cp) {
7367
- if (cp < 2048) return BYTE_HEX[192 | cp >> 6] + BYTE_HEX[128 | cp & 63];
7368
- if (cp < 65536) return BYTE_HEX[224 | cp >> 12] + BYTE_HEX[128 | cp >> 6 & 63] + BYTE_HEX[128 | cp & 63];
7369
- return BYTE_HEX[240 | cp >> 18] + BYTE_HEX[128 | cp >> 12 & 63] + BYTE_HEX[128 | cp >> 6 & 63] + BYTE_HEX[128 | cp & 63];
7370
- }
7391
+ /** @type {(value: string) => boolean} */
7392
+ var isRegNameCharacter = RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=]$/u);
7393
+ /** @type {(value: string) => boolean} */
7394
+ var isLiteralRegName = RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=]*$/u);
7371
7395
  /**
7372
7396
  * @param {Array<string>} input
7373
7397
  * @returns {string}
@@ -7401,6 +7425,27 @@ var require_utils = /* @__PURE__ */ __commonJSMin(((exports, module) => {
7401
7425
  * @returns {boolean}
7402
7426
  */
7403
7427
  var nonSimpleDomain = RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);
7428
+ /** @type {(value: string) => boolean} */
7429
+ var nonSimpleDomainChars = RegExp.prototype.test.bind(/[^\d!"$&'()*+,\-.;=_`a-z{}~]/u);
7430
+ /** @type {(value: string) => boolean} */
7431
+ var numericLastLabel = RegExp.prototype.test.bind(/(?:^|\.)\d+$/u);
7432
+ /**
7433
+ * True when `new URL('http://' + domain).hostname` may differ from `domain`,
7434
+ * i.e. when the caller must fall back to the WHATWG parser.
7435
+ *
7436
+ * Same purpose as `nonSimpleDomain`, but digits are allowed: for this character
7437
+ * set `hostname` is the identity, *except* that an all-numeric final label is
7438
+ * read as IPv4 shorthand ("1.2.3" -> "1.2.0.3", "127.1" -> "127.0.0.1",
7439
+ * "a.b.1" throws), which is why `nonSimpleDomain` excludes digits outright.
7440
+ * Rejecting that one shape lets the common `mail2.example.org` case stay on the
7441
+ * fast path.
7442
+ *
7443
+ * @param {string} domain - must already be lowercased
7444
+ * @returns {boolean}
7445
+ */
7446
+ function nonSimpleMailtoDomain(domain) {
7447
+ return nonSimpleDomainChars(domain) || numericLastLabel(domain);
7448
+ }
7404
7449
  /**
7405
7450
  * @param {string} zone
7406
7451
  * @returns {boolean}
@@ -7587,7 +7632,7 @@ var require_utils = /* @__PURE__ */ __commonJSMin(((exports, module) => {
7587
7632
  continue;
7588
7633
  }
7589
7634
  } else if (input[0] === "/") {
7590
- if (input[1] === "." || input[1] === "/") {
7635
+ if (input[1] === ".") {
7591
7636
  output.push("/");
7592
7637
  break;
7593
7638
  }
@@ -7666,28 +7711,30 @@ var require_utils = /* @__PURE__ */ __commonJSMin(((exports, module) => {
7666
7711
  return output.join("/");
7667
7712
  }
7668
7713
  /**
7669
- * Re-escape RFC 3986 gen-delims that must not appear literally in the host.
7670
- * After the URI regex parses, these characters cannot be literal in the host
7671
- * field, so any that appear after decoding came from percent-encoding and
7672
- * must be restored to prevent authority structure changes.
7714
+ * Encodes a host according to the RFC 3986 host grammar. Valid IP literals
7715
+ * have already been checked by `normalizeIPv6`, so their address separators
7716
+ * remain literal. Every other host is a reg-name and may contain only
7717
+ * unreserved characters, sub-delimiters, and valid percent escapes.
7673
7718
  *
7674
7719
  * @param {string} host
7675
- * @param {boolean} isIP - true for IPv4/IPv6 hosts (skip colon re-escaping)
7720
+ * @param {boolean} isIP - true for a validated IPv4/IPv6 host
7721
+ * @param {boolean} [allowNonAscii=false] - preserve non-ASCII IRI characters
7676
7722
  * @returns {string}
7677
7723
  */
7678
- var HOST_DELIMS = {
7724
+ var IP_HOST_DELIMS = {
7679
7725
  "@": "%40",
7680
7726
  "/": "%2F",
7681
7727
  "?": "%3F",
7682
- "#": "%23",
7683
- ":": "%3A"
7728
+ "#": "%23"
7684
7729
  };
7685
- var HOST_DELIM_RE = /[@/?#:]/g;
7686
- var HOST_DELIM_NO_COLON_RE = /[@/?#]/g;
7687
- function reescapeHostDelimiters(host, isIP) {
7688
- const re = isIP ? HOST_DELIM_NO_COLON_RE : HOST_DELIM_RE;
7689
- re.lastIndex = 0;
7690
- return host.replace(re, (ch) => HOST_DELIMS[ch]);
7730
+ var IP_HOST_DELIM_RE = /[@/?#]/g;
7731
+ function encodeHost(host, isIP, allowNonAscii = false) {
7732
+ if (!isIP) {
7733
+ if (isLiteralRegName(host)) return host;
7734
+ return encodeComponent(host, isRegNameCharacter, allowNonAscii);
7735
+ }
7736
+ IP_HOST_DELIM_RE.lastIndex = 0;
7737
+ return host.replace(IP_HOST_DELIM_RE, (ch) => IP_HOST_DELIMS[ch]);
7691
7738
  }
7692
7739
  /**
7693
7740
  * Normalizes percent escapes and optionally decodes only unreserved ASCII bytes.
@@ -7716,6 +7763,34 @@ var require_utils = /* @__PURE__ */ __commonJSMin(((exports, module) => {
7716
7763
  }
7717
7764
  return output;
7718
7765
  }
7766
+ /** Pre-built `%XX` strings for every byte. Avoids per-call hex math/concat. */
7767
+ var BYTE_HEX = new Array(256);
7768
+ {
7769
+ const HEX_DIGITS = "0123456789ABCDEF";
7770
+ for (let i = 0; i < 256; i++) BYTE_HEX[i] = "%" + HEX_DIGITS[i >> 4] + HEX_DIGITS[i & 15];
7771
+ }
7772
+ /**
7773
+ * Mirrors the pass-through set of the deprecated `escape()` global:
7774
+ * `A-Z a-z 0-9 * + - . / @ _`. Keeps drop-in semantics for ASCII input.
7775
+ *
7776
+ * @param {number} cp
7777
+ * @returns {boolean}
7778
+ */
7779
+ function isEscapeSafe(cp) {
7780
+ return cp >= 48 && cp <= 57 || cp >= 65 && cp <= 90 || cp >= 97 && cp <= 122 || cp === 42 || cp === 43 || cp === 45 || cp === 46 || cp === 47 || cp === 64 || cp === 95;
7781
+ }
7782
+ /**
7783
+ * RFC 3986 percent-encode a non-ASCII Unicode code point as UTF-8 bytes.
7784
+ * Caller handles the ASCII branch inline for speed.
7785
+ *
7786
+ * @param {number} cp - Unicode code point (>= 0x80, <= 0x10FFFF)
7787
+ * @returns {string}
7788
+ */
7789
+ function percentEncodeNonAscii(cp) {
7790
+ if (cp < 2048) return BYTE_HEX[192 | cp >> 6] + BYTE_HEX[128 | cp & 63];
7791
+ if (cp < 65536) return BYTE_HEX[224 | cp >> 12] + BYTE_HEX[128 | cp >> 6 & 63] + BYTE_HEX[128 | cp & 63];
7792
+ return BYTE_HEX[240 | cp >> 18] + BYTE_HEX[128 | cp >> 12 & 63] + BYTE_HEX[128 | cp >> 6 & 63] + BYTE_HEX[128 | cp & 63];
7793
+ }
7719
7794
  /**
7720
7795
  * Normalizes path data without turning reserved escapes into live path syntax.
7721
7796
  * Valid escapes are uppercased, raw unsafe characters are escaped, and only
@@ -7796,14 +7871,56 @@ var require_utils = /* @__PURE__ */ __commonJSMin(((exports, module) => {
7796
7871
  return output;
7797
7872
  }
7798
7873
  /**
7874
+ * Normalizes the percent-encoding of a query or fragment component.
7875
+ *
7876
+ * Like `normalizePathEncoding`, but uses the query/fragment character set
7877
+ * (which additionally allows `?`) and decodes `.` since it has no dot-segment
7878
+ * meaning outside of a path.
7879
+ *
7880
+ * @param {string} input
7881
+ * @returns {string}
7882
+ */
7883
+ function normalizeQueryFragmentEncoding(input) {
7884
+ let output = "";
7885
+ for (let i = 0; i < input.length; i++) {
7886
+ const ch = input[i];
7887
+ if (ch === "%" && i + 2 < input.length) {
7888
+ const hex = input.slice(i + 1, i + 3);
7889
+ if (isHexPair(hex)) {
7890
+ const normalizedHex = hex.toUpperCase();
7891
+ const decoded = String.fromCharCode(parseInt(normalizedHex, 16));
7892
+ if (isUnreserved(decoded)) output += decoded;
7893
+ else output += "%" + normalizedHex;
7894
+ i += 2;
7895
+ continue;
7896
+ }
7897
+ }
7898
+ if (isQueryFragmentCharacter(ch)) output += ch;
7899
+ else {
7900
+ const code = input.charCodeAt(i);
7901
+ if (code < 128) output += isEscapeSafe(code) ? ch : BYTE_HEX[code];
7902
+ else if (code < 55296 || code > 57343) output += percentEncodeNonAscii(code);
7903
+ else if (code <= 56319 && i + 1 < input.length) {
7904
+ const low = input.charCodeAt(i + 1);
7905
+ if (low >= 56320 && low <= 57343) {
7906
+ output += percentEncodeNonAscii(65536 + (code - 55296 << 10) + (low - 56320));
7907
+ i++;
7908
+ } else output += percentEncodeNonAscii(65533);
7909
+ } else output += percentEncodeNonAscii(65533);
7910
+ }
7911
+ }
7912
+ return output;
7913
+ }
7914
+ /**
7799
7915
  * Percent-encodes a URI component using its RFC 3986 literal character set.
7800
7916
  * Existing valid escapes are preserved and normalized to uppercase hex.
7801
7917
  *
7802
7918
  * @param {string} input
7803
7919
  * @param {(value: string) => boolean} isAllowed
7920
+ * @param {boolean} [allowNonAscii=false]
7804
7921
  * @returns {string}
7805
7922
  */
7806
- function encodeComponent(input, isAllowed) {
7923
+ function encodeComponent(input, isAllowed, allowNonAscii = false) {
7807
7924
  let output = "";
7808
7925
  for (let i = 0; i < input.length; i++) {
7809
7926
  const ch = input[i];
@@ -7819,14 +7936,14 @@ var require_utils = /* @__PURE__ */ __commonJSMin(((exports, module) => {
7819
7936
  else {
7820
7937
  const code = input.charCodeAt(i);
7821
7938
  if (code < 128) output += BYTE_HEX[code];
7822
- else if (code < 55296 || code > 57343) output += percentEncodeNonAscii(code);
7939
+ else if (code < 55296 || code > 57343) output += allowNonAscii ? ch : percentEncodeNonAscii(code);
7823
7940
  else if (code <= 56319 && i + 1 < input.length) {
7824
7941
  const low = input.charCodeAt(i + 1);
7825
7942
  if (low >= 56320 && low <= 57343) {
7826
- output += percentEncodeNonAscii(65536 + (code - 55296 << 10) + (low - 56320));
7943
+ output += allowNonAscii ? ch + input[i + 1] : percentEncodeNonAscii(65536 + (code - 55296 << 10) + (low - 56320));
7827
7944
  i++;
7828
- } else output += percentEncodeNonAscii(65533);
7829
- } else output += percentEncodeNonAscii(65533);
7945
+ } else output += allowNonAscii ? "�" : percentEncodeNonAscii(65533);
7946
+ } else output += allowNonAscii ? "�" : percentEncodeNonAscii(65533);
7830
7947
  }
7831
7948
  }
7832
7949
  return output;
@@ -7860,76 +7977,65 @@ var require_utils = /* @__PURE__ */ __commonJSMin(((exports, module) => {
7860
7977
  function encodeFragment(input) {
7861
7978
  return encodeComponent(input, isQueryFragmentCharacter);
7862
7979
  }
7863
- function isEscapeSafe(cp) {
7864
- return cp >= 48 && cp <= 57 || cp >= 65 && cp <= 90 || cp >= 97 && cp <= 122 || cp === 42 || cp === 43 || cp === 45 || cp === 46 || cp === 47 || cp === 64 || cp === 95;
7865
- }
7866
7980
  /**
7867
- * Normalizes the percent-encoding of a query or fragment component.
7868
- *
7869
- * Like `normalizePathEncoding`, but uses the query/fragment character set
7870
- * (which additionally allows `?`) and decodes `.` since it has no dot-segment
7871
- * meaning outside of a path.
7981
+ * Escapes a component while preserving existing valid percent escapes.
7872
7982
  *
7873
7983
  * @param {string} input
7874
7984
  * @returns {string}
7875
7985
  */
7876
- function normalizeQueryFragmentEncoding(input) {
7986
+ function escapePreservingEscapes(input) {
7877
7987
  let output = "";
7878
7988
  for (let i = 0; i < input.length; i++) {
7879
7989
  const ch = input[i];
7880
7990
  if (ch === "%" && i + 2 < input.length) {
7881
7991
  const hex = input.slice(i + 1, i + 3);
7882
7992
  if (isHexPair(hex)) {
7883
- const normalizedHex = hex.toUpperCase();
7884
- const decoded = String.fromCharCode(parseInt(normalizedHex, 16));
7885
- if (isUnreserved(decoded)) output += decoded;
7886
- else output += "%" + normalizedHex;
7993
+ output += "%" + hex.toUpperCase();
7887
7994
  i += 2;
7888
7995
  continue;
7889
7996
  }
7890
7997
  }
7891
- if (isQueryFragmentCharacter(ch)) output += ch;
7892
- else {
7893
- const code = input.charCodeAt(i);
7894
- if (code < 128) output += isEscapeSafe(code) ? ch : BYTE_HEX[code];
7895
- else if (code < 55296 || code > 57343) output += percentEncodeNonAscii(code);
7896
- else if (code <= 56319 && i + 1 < input.length) {
7897
- const low = input.charCodeAt(i + 1);
7898
- if (low >= 56320 && low <= 57343) {
7899
- output += percentEncodeNonAscii(65536 + (code - 55296 << 10) + (low - 56320));
7900
- i++;
7901
- } else output += percentEncodeNonAscii(65533);
7998
+ const code = input.charCodeAt(i);
7999
+ if (code < 128) output += isEscapeSafe(code) ? ch : BYTE_HEX[code];
8000
+ else if (code < 55296 || code > 57343) output += percentEncodeNonAscii(code);
8001
+ else if (code <= 56319 && i + 1 < input.length) {
8002
+ const low = input.charCodeAt(i + 1);
8003
+ if (low >= 56320 && low <= 57343) {
8004
+ output += percentEncodeNonAscii(65536 + (code - 55296 << 10) + (low - 56320));
8005
+ i++;
7902
8006
  } else output += percentEncodeNonAscii(65533);
7903
- }
8007
+ } else output += percentEncodeNonAscii(65533);
7904
8008
  }
7905
8009
  return output;
7906
8010
  }
7907
8011
  /**
7908
- * Escapes a component while preserving existing valid percent escapes.
8012
+ * Rebuilds the bracketed form of a zoned IPv6 authority from the current
8013
+ * `component.host` and its zone identifier (`component.ipv6Zone`), but only
8014
+ * when they are consistent and describe a real zoned IPv6 literal that
8015
+ * normalizes back to `component.host`. This validates the zone on use, so a
8016
+ * caller-supplied `ipv6Zone` that does not match the host (or a host
8017
+ * reassigned after `parse`) is never trusted and recomposition falls back to
8018
+ * the normal path.
7909
8019
  *
7910
- * @param {string} input
7911
- * @returns {string}
8020
+ * @param {import('../types/index').URIComponent} component
8021
+ * @returns {string|undefined}
7912
8022
  */
7913
- function escapePreservingEscapes(input) {
7914
- let output = "";
7915
- for (let i = 0; i < input.length; i++) {
7916
- if (input[i] === "%" && i + 2 < input.length) {
7917
- const hex = input.slice(i + 1, i + 3);
7918
- if (isHexPair(hex)) {
7919
- output += "%" + hex.toUpperCase();
7920
- i += 2;
7921
- continue;
7922
- }
7923
- }
7924
- output += escape(input[i]);
7925
- }
7926
- return output;
8023
+ function recomposeZonedIPv6Host(component) {
8024
+ const zone = component.ipv6Zone;
8025
+ if (zone === void 0) return void 0;
8026
+ const host = component.host;
8027
+ const separator = host.indexOf("%");
8028
+ if (separator === -1) return void 0;
8029
+ const escaped = host.slice(0, separator) + "%25" + zone;
8030
+ const derived = normalizeIPv6("[" + escaped + "]");
8031
+ if (derived.isIPV6 === true && derived.host === host) return "[" + escaped + "]";
7927
8032
  }
7928
8033
  /**
7929
8034
  * @param {import('../types/index').URIComponent} component
8035
+ * @param {boolean} [allowNonAscii=false] - preserve non-ASCII IRI characters
7930
8036
  * @returns {string|undefined}
7931
8037
  */
7932
- function recomposeAuthority(component) {
8038
+ function recomposeAuthority(component, allowNonAscii = false) {
7933
8039
  const uriTokens = [];
7934
8040
  if (component.userinfo !== void 0) {
7935
8041
  uriTokens.push(encodeUserinfo(component.userinfo));
@@ -7938,13 +8044,17 @@ var require_utils = /* @__PURE__ */ __commonJSMin(((exports, module) => {
7938
8044
  if (component.host !== void 0) {
7939
8045
  let host = component.host;
7940
8046
  if (!isIPv4(host)) {
7941
- let ipV6res = normalizeIPv6(host);
7942
- if (ipV6res.isIPV6 !== true && ipV6res.isIPVFuture !== true) {
7943
- host = normalizePercentEncoding(host, true);
7944
- ipV6res = normalizeIPv6(host);
8047
+ const zonedHost = recomposeZonedIPv6Host(component);
8048
+ if (zonedHost !== void 0) host = zonedHost;
8049
+ else {
8050
+ let ipV6res = normalizeIPv6(host);
8051
+ if (ipV6res.isIPV6 !== true && ipV6res.isIPVFuture !== true) {
8052
+ host = normalizePercentEncoding(host, true);
8053
+ ipV6res = normalizeIPv6(host);
8054
+ }
8055
+ if (ipV6res.isIPV6 === true || ipV6res.isIPVFuture === true) host = `[${ipV6res.escapedHost}]`;
8056
+ else host = encodeHost(host, false, allowNonAscii);
7945
8057
  }
7946
- if (ipV6res.isIPV6 === true || ipV6res.isIPVFuture === true) host = `[${ipV6res.escapedHost}]`;
7947
- else host = reescapeHostDelimiters(host, false);
7948
8058
  }
7949
8059
  uriTokens.push(host);
7950
8060
  }
@@ -7957,9 +8067,12 @@ var require_utils = /* @__PURE__ */ __commonJSMin(((exports, module) => {
7957
8067
  return uriTokens.length ? uriTokens.join("") : void 0;
7958
8068
  }
7959
8069
  module.exports = {
8070
+ BYTE_HEX,
8071
+ percentEncodeNonAscii,
7960
8072
  nonSimpleDomain,
8073
+ nonSimpleMailtoDomain,
7961
8074
  recomposeAuthority,
7962
- reescapeHostDelimiters,
8075
+ encodeHost,
7963
8076
  normalizePercentEncoding,
7964
8077
  normalizePathEncoding,
7965
8078
  serializePathEncoding,
@@ -7977,7 +8090,7 @@ var require_utils = /* @__PURE__ */ __commonJSMin(((exports, module) => {
7977
8090
  };
7978
8091
  }));
7979
8092
  var require_schemes = /* @__PURE__ */ __commonJSMin(((exports, module) => {
7980
- var { isUUID } = require_utils();
8093
+ var { isUUID, BYTE_HEX, percentEncodeNonAscii, nonSimpleMailtoDomain } = require_utils();
7981
8094
  var URN_REG = /^([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-./:;=@]|%[\da-f]{2})+)$/iu;
7982
8095
  var supportedSchemeNames = [
7983
8096
  "http",
@@ -7985,7 +8098,8 @@ var require_schemes = /* @__PURE__ */ __commonJSMin(((exports, module) => {
7985
8098
  "ws",
7986
8099
  "wss",
7987
8100
  "urn",
7988
- "urn:uuid"
8101
+ "urn:uuid",
8102
+ "mailto"
7989
8103
  ];
7990
8104
  /** @typedef {supportedSchemeNames[number]} SchemeName */
7991
8105
  /**
@@ -8120,27 +8234,333 @@ var require_schemes = /* @__PURE__ */ __commonJSMin(((exports, module) => {
8120
8234
  parse: wsParse,
8121
8235
  serialize: wsSerialize
8122
8236
  };
8237
+ var wss = {
8238
+ scheme: "wss",
8239
+ domainHost: ws.domainHost,
8240
+ parse: ws.parse,
8241
+ serialize: ws.serialize
8242
+ };
8243
+ var urn = {
8244
+ scheme: "urn",
8245
+ parse: urnParse,
8246
+ serialize: urnSerialize,
8247
+ skipNormalize: true,
8248
+ absolutePath: true
8249
+ };
8250
+ var urnuuid = {
8251
+ scheme: "urn:uuid",
8252
+ parse: urnuuidParse,
8253
+ serialize: urnuuidSerialize,
8254
+ skipNormalize: true
8255
+ };
8256
+ /**
8257
+ * Allow-sets for `encodeWithAllow`, each a `{ all, table, allowNonAscii }`
8258
+ * descriptor built by `allowSet`:
8259
+ *
8260
+ * - `LOCAL_PART` is the intersection of upstream uri-js's VCHAR and
8261
+ * NOT_PATH_NOSCHEME, minus ",": the serializer joins recipients with "," and
8262
+ * `mailtoParse` splits the path on it, so a comma left literal inside a local
8263
+ * part would silently become a recipient delimiter.
8264
+ * - `HFNAME` is the qchar allow-set used for header names/values.
8265
+ * - `DTEXT` is RFC 6068 dtext-no-obs restricted to characters that are also
8266
+ * safe in a URI path; `DTEXT_IRI` additionally permits non-ASCII for
8267
+ * `unicodeSupport`.
8268
+ */
8269
+ var LOCAL_PART_ALLOWED = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~!$'()*+=";
8270
+ var HFNAME_ALLOWED = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~!$'()*+,;:@";
8271
+ var DTEXT_ALLOWED = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~!$'()*+;:";
8272
+ /**
8273
+ * @typedef {Object} AllowSet
8274
+ * @property {RegExp} all - matches a whole string needing no encoding at all.
8275
+ * @property {Uint8Array} table - per-ASCII-code allow lookup for the slow path.
8276
+ * @property {boolean} allowNonAscii - pass non-ASCII code points through (IRI).
8277
+ */
8278
+ /**
8279
+ * `all` deliberately excludes "%" and (for the IRI variant) surrogates, so any
8280
+ * input needing escape normalization or surrogate repair falls to the slow path.
8281
+ *
8282
+ * @param {string} chars
8283
+ * @param {boolean} [allowNonAscii=false]
8284
+ * @returns {AllowSet}
8285
+ */
8286
+ function allowSet(chars, allowNonAscii = false) {
8287
+ const table = /* @__PURE__ */ new Uint8Array(128);
8288
+ for (let i = 0; i < chars.length; i++) table[chars.charCodeAt(i)] = 1;
8289
+ const escaped = chars.replace(/[\\\]^-]/gu, "\\$&");
8290
+ const cls = allowNonAscii ? `[${escaped}]|[^\\0-\\x7F\\uD800-\\uDFFF]` : `[${escaped}]`;
8291
+ return {
8292
+ all: new RegExp(`^(?:${cls})*$`, "u"),
8293
+ table,
8294
+ allowNonAscii
8295
+ };
8296
+ }
8297
+ var LOCAL_PART = allowSet(LOCAL_PART_ALLOWED);
8298
+ var HFNAME = allowSet(HFNAME_ALLOWED);
8299
+ var DTEXT = allowSet(DTEXT_ALLOWED);
8300
+ var DTEXT_IRI = allowSet(DTEXT_ALLOWED, true);
8301
+ var HEX_PAIR = /^[\da-f]{2}$/iu;
8302
+ var MAILTO_DOMAIN_LITERAL = /^\[[\x21-\x5A\x5E-\x7E]*\]$/u;
8303
+ var MAILTO_DOMAIN_ERROR = "URI mailto has an invalid recipient domain.";
8304
+ var MAILTO_AUTHORITY_ERROR = "URI mailto must not have an authority component.";
8305
+ var HAS_SURROGATE = /[\uD800-\uDFFF]/u;
8306
+ /**
8307
+ * @param {string} str
8308
+ * @returns {string}
8309
+ */
8310
+ function decodeHex(str) {
8311
+ if (typeof str !== "string" || str.indexOf("%") === -1) return str;
8312
+ try {
8313
+ return decodeURIComponent(str);
8314
+ } catch {
8315
+ return str;
8316
+ }
8317
+ }
8318
+ /**
8319
+ * Replaces lone surrogates with U+FFFD, leaving valid pairs intact. Only called
8320
+ * when `HAS_SURROGATE` matched, so the scan cost is not on the common path.
8321
+ * (`String.prototype.toWellFormed` would do this natively but is Node 20+.)
8322
+ *
8323
+ * @param {string} input
8324
+ * @returns {string}
8325
+ */
8326
+ function replaceLoneSurrogates(input) {
8327
+ let result = "";
8328
+ for (let i = 0; i < input.length; i++) {
8329
+ const code = input.charCodeAt(i);
8330
+ if (code >= 55296 && code <= 56319 && i + 1 < input.length) {
8331
+ const low = input.charCodeAt(i + 1);
8332
+ if (low >= 56320 && low <= 57343) {
8333
+ result += input[i] + input[i + 1];
8334
+ i++;
8335
+ continue;
8336
+ }
8337
+ }
8338
+ result += code >= 55296 && code <= 57343 ? "�" : input[i];
8339
+ }
8340
+ return result;
8341
+ }
8342
+ /**
8343
+ * Percent-encodes everything outside `set`, preserving existing valid escapes
8344
+ * (uppercased) and repairing lone surrogates.
8345
+ *
8346
+ * ASCII uses `BYTE_HEX` rather than `encodeURIComponent`. That is equivalent
8347
+ * only because every character `encodeURIComponent` leaves unescaped
8348
+ * (`A-Za-z0-9-_.!~*'()`) is present in all of the allow-sets above, so no such
8349
+ * character ever reaches the encode branch. Re-check if a set is narrowed.
8350
+ *
8351
+ * @param {string} input
8352
+ * @param {AllowSet} set
8353
+ * @returns {string}
8354
+ */
8355
+ function encodeWithAllow(input, set) {
8356
+ if (set.all.test(input)) return input;
8357
+ const table = set.table;
8358
+ let result = "";
8359
+ for (let i = 0; i < input.length; i++) {
8360
+ const code = input.charCodeAt(i);
8361
+ if (code < 128) {
8362
+ if (table[code] === 1) result += input[i];
8363
+ else if (code === 37 && i + 2 < input.length && HEX_PAIR.test(input.slice(i + 1, i + 3))) {
8364
+ result += "%" + input.slice(i + 1, i + 3).toUpperCase();
8365
+ i += 2;
8366
+ } else result += BYTE_HEX[code];
8367
+ continue;
8368
+ }
8369
+ if (code < 55296 || code > 57343) {
8370
+ result += set.allowNonAscii ? input[i] : percentEncodeNonAscii(code);
8371
+ continue;
8372
+ }
8373
+ if (code <= 56319 && i + 1 < input.length) {
8374
+ const low = input.charCodeAt(i + 1);
8375
+ if (low >= 56320 && low <= 57343) {
8376
+ result += set.allowNonAscii ? input[i] + input[i + 1] : percentEncodeNonAscii(65536 + (code - 55296 << 10) + (low - 56320));
8377
+ i++;
8378
+ continue;
8379
+ }
8380
+ }
8381
+ result += set.allowNonAscii ? "�" : percentEncodeNonAscii(65533);
8382
+ }
8383
+ return result;
8384
+ }
8385
+ /**
8386
+ * @param {string} domain
8387
+ * @param {import('../types/index').Options} [options]
8388
+ * @param {{error?:string}} [component]
8389
+ * @returns {string}
8390
+ */
8391
+ function mailtoNormalizeDomain(domain, options, component) {
8392
+ const normalizedDomain = String(domain).toLowerCase();
8393
+ if (MAILTO_DOMAIN_LITERAL.test(normalizedDomain)) return normalizedDomain;
8394
+ if (normalizedDomain !== "" && !nonSimpleMailtoDomain(normalizedDomain)) return normalizedDomain;
8395
+ try {
8396
+ const parsedDomain = new URL("http://" + normalizedDomain);
8397
+ if (parsedDomain.username || parsedDomain.password || parsedDomain.port || parsedDomain.pathname !== "/" || parsedDomain.search || parsedDomain.hash || !parsedDomain.hostname) throw new Error(MAILTO_DOMAIN_ERROR);
8398
+ return options && options.unicodeSupport ? normalizedDomain : parsedDomain.hostname;
8399
+ } catch {
8400
+ if (component) component.error = component.error || MAILTO_DOMAIN_ERROR;
8401
+ return normalizedDomain;
8402
+ }
8403
+ }
8404
+ /**
8405
+ * Percent-encodes everything in a recipient domain that is not `dtext-no-obs`
8406
+ * (RFC 6068). Serialize-only: `mailtoNormalizeDomain` returns the domain
8407
+ * verbatim when validation fails, and `MAILTO_DOMAIN_LITERAL` accepts the full
8408
+ * RFC 5321 dcontent range (which includes "?", "#", "&" and "/"), so without
8409
+ * this an attacker-supplied recipient could inject header fields or a fragment
8410
+ * into the serialized URI. `mailtoParse` deliberately reports the raw domain
8411
+ * instead, so it must not use this.
8412
+ * @param {string} domain
8413
+ * @param {import('../types/index').Options} [options]
8414
+ * @returns {string}
8415
+ */
8416
+ function mailtoEncodeDomain(domain, options) {
8417
+ const set = options && options.unicodeSupport ? DTEXT_IRI : DTEXT;
8418
+ if (domain.length > 1 && domain[0] === "[" && domain[domain.length - 1] === "]") return "[" + encodeWithAllow(domain.slice(1, -1), set) + "]";
8419
+ return encodeWithAllow(domain, set);
8420
+ }
8421
+ /**
8422
+ * @param {import('../types/index').URIComponent} component
8423
+ * @param {import('../types/index').Options} options
8424
+ * @returns {import('../types/index').URIComponent}
8425
+ */
8426
+ function mailtoParse(component, options) {
8427
+ const mailtoComponent = component;
8428
+ let rawPath = mailtoComponent.path;
8429
+ let rawQuery = mailtoComponent.query;
8430
+ if (rawPath && HAS_SURROGATE.test(rawPath)) rawPath = replaceLoneSurrogates(rawPath);
8431
+ if (rawQuery && HAS_SURROGATE.test(rawQuery)) rawQuery = replaceLoneSurrogates(rawQuery);
8432
+ const to = rawPath ? rawPath.indexOf(",") === -1 ? [rawPath] : rawPath.split(",") : [];
8433
+ mailtoComponent.path = void 0;
8434
+ if (rawQuery) {
8435
+ /** @type {Record<string,string>|null} */
8436
+ let headers = null;
8437
+ let start = 0;
8438
+ while (start <= rawQuery.length) {
8439
+ let end = rawQuery.indexOf("&", start);
8440
+ if (end === -1) end = rawQuery.length;
8441
+ const token = rawQuery.slice(start, end);
8442
+ start = end + 1;
8443
+ const eqIdx = token.indexOf("=");
8444
+ if (eqIdx !== token.lastIndexOf("=")) {
8445
+ mailtoComponent.error = mailtoComponent.error || "URI mailto has malformed header fields.";
8446
+ continue;
8447
+ }
8448
+ const name = decodeHex(eqIdx === -1 ? token : token.slice(0, eqIdx));
8449
+ const normalizedName = name.toLowerCase();
8450
+ const value = eqIdx === -1 ? "" : token.slice(eqIdx + 1);
8451
+ if (normalizedName === "to") {
8452
+ const addrs = value.split(",");
8453
+ for (let j = 0; j < addrs.length; j++) to.push(addrs[j]);
8454
+ continue;
8455
+ }
8456
+ if (normalizedName === "subject") {
8457
+ mailtoComponent.subject = decodeHex(value);
8458
+ continue;
8459
+ }
8460
+ if (normalizedName === "body") {
8461
+ mailtoComponent.body = decodeHex(value);
8462
+ continue;
8463
+ }
8464
+ if (headers === null) headers = Object.create(null);
8465
+ headers[name] = decodeHex(value);
8466
+ }
8467
+ if (headers !== null) mailtoComponent.headers = headers;
8468
+ }
8469
+ mailtoComponent.query = void 0;
8470
+ if (to.length > 0 && (mailtoComponent.userinfo !== void 0 || mailtoComponent.host !== void 0 || mailtoComponent.port !== void 0)) {
8471
+ mailtoComponent.userinfo = void 0;
8472
+ mailtoComponent.host = void 0;
8473
+ mailtoComponent.port = void 0;
8474
+ mailtoComponent.error = mailtoComponent.error || MAILTO_AUTHORITY_ERROR;
8475
+ }
8476
+ for (let i = 0; i < to.length; i++) {
8477
+ const rawAddr = to[i];
8478
+ const atIdx = rawAddr.lastIndexOf("@");
8479
+ if (atIdx < 0) {
8480
+ mailtoComponent.error = mailtoComponent.error || MAILTO_DOMAIN_ERROR;
8481
+ to[i] = decodeHex(rawAddr);
8482
+ continue;
8483
+ }
8484
+ const local = decodeHex(rawAddr.slice(0, atIdx));
8485
+ const domain = mailtoNormalizeDomain(decodeHex(rawAddr.slice(atIdx + 1)), options, mailtoComponent);
8486
+ to[i] = local + "@" + domain;
8487
+ }
8488
+ if (to.length) mailtoComponent.to = to;
8489
+ return mailtoComponent;
8490
+ }
8491
+ /**
8492
+ * Encodes a decoded mailto header name. Unlike `encodeWithAllow`, a percent
8493
+ * sign is always data here, even when followed by two hex digits. Preserving
8494
+ * such a sequence as an existing escape would decode the name again on the
8495
+ * next parse and could turn a generic header into `to`, `subject`, or `body`.
8496
+ * @param {string} name
8497
+ * @returns {string}
8498
+ */
8499
+ function mailtoEncodeHeaderName(name) {
8500
+ return encodeWithAllow(name.replace(/%/gu, "%25"), HFNAME);
8501
+ }
8502
+ /**
8503
+ * @param {import('../types/index').URIComponent} component
8504
+ * @param {import('../types/index').Options} options
8505
+ * @returns {import('../types/index').URIComponent}
8506
+ */
8507
+ function mailtoSerialize(component, options) {
8508
+ const mailtoComponent = component;
8509
+ const to = Array.isArray(mailtoComponent.to) ? mailtoComponent.to.slice() : [];
8510
+ const sourceHeaders = mailtoComponent.headers && typeof mailtoComponent.headers === "object" ? Object.assign(Object.create(null), mailtoComponent.headers) : Object.create(null);
8511
+ const headers = Object.create(null);
8512
+ for (const name in sourceHeaders) {
8513
+ const normalizedName = name.toLowerCase();
8514
+ if (normalizedName === "to") {
8515
+ const addrs = String(sourceHeaders[name]).split(",");
8516
+ for (let i = 0; i < addrs.length; i++) to.push(addrs[i]);
8517
+ } else if (normalizedName === "subject" || normalizedName === "body") headers[normalizedName] = sourceHeaders[name];
8518
+ else headers[name] = sourceHeaders[name];
8519
+ }
8520
+ if (mailtoComponent.subject !== void 0) headers.subject = mailtoComponent.subject;
8521
+ if (mailtoComponent.body !== void 0) headers.body = mailtoComponent.body;
8522
+ mailtoComponent.headers = headers;
8523
+ if (to.length) {
8524
+ mailtoComponent.userinfo = void 0;
8525
+ mailtoComponent.host = void 0;
8526
+ mailtoComponent.port = void 0;
8527
+ for (let i = 0; i < to.length; i++) {
8528
+ const addr = String(to[i]);
8529
+ const atIdx = addr.lastIndexOf("@");
8530
+ const rawLocal = atIdx >= 0 ? addr.slice(0, atIdx) : addr;
8531
+ const rawDomain = atIdx >= 0 ? addr.slice(atIdx + 1) : "";
8532
+ const local = encodeWithAllow(rawLocal, LOCAL_PART);
8533
+ const normalizedDomain = mailtoNormalizeDomain(decodeHex(rawDomain), options);
8534
+ to[i] = local + "@" + mailtoEncodeDomain(normalizedDomain, options);
8535
+ }
8536
+ mailtoComponent.path = to.join(",");
8537
+ options.skipEscape = true;
8538
+ } else mailtoComponent.path = void 0;
8539
+ let query = "";
8540
+ let count = 0;
8541
+ for (const name in headers) {
8542
+ if (count++ !== 0) query += "&";
8543
+ query += mailtoEncodeHeaderName(name) + "=" + encodeWithAllow(String(headers[name]), HFNAME);
8544
+ }
8545
+ if (count !== 0) mailtoComponent.query = query;
8546
+ else mailtoComponent.headers = void 0;
8547
+ return mailtoComponent;
8548
+ }
8123
8549
  var SCHEMES = {
8124
8550
  http,
8125
8551
  https,
8126
8552
  ws,
8127
- wss: {
8128
- scheme: "wss",
8129
- domainHost: ws.domainHost,
8130
- parse: ws.parse,
8131
- serialize: ws.serialize
8132
- },
8133
- urn: {
8134
- scheme: "urn",
8135
- parse: urnParse,
8136
- serialize: urnSerialize,
8137
- skipNormalize: true
8138
- },
8139
- "urn:uuid": {
8140
- scheme: "urn:uuid",
8141
- parse: urnuuidParse,
8142
- serialize: urnuuidSerialize,
8143
- skipNormalize: true
8553
+ wss,
8554
+ urn,
8555
+ "urn:uuid": urnuuid,
8556
+ mailto: {
8557
+ scheme: "mailto",
8558
+ parse: mailtoParse,
8559
+ serialize: mailtoSerialize,
8560
+ domainHost: false,
8561
+ unicodeSupport: true,
8562
+ skipNormalize: true,
8563
+ absolutePath: true
8144
8564
  }
8145
8565
  };
8146
8566
  Object.setPrototypeOf(SCHEMES, null);
@@ -8159,7 +8579,7 @@ var require_schemes = /* @__PURE__ */ __commonJSMin(((exports, module) => {
8159
8579
  };
8160
8580
  }));
8161
8581
  var require_fast_uri = /* @__PURE__ */ __commonJSMin(((exports, module) => {
8162
- var { normalizeIPv6, removeDotSegments, removeDotSegmentsRelative, recomposeAuthority, normalizePercentEncoding, normalizePathEncoding, serializePathEncoding, normalizeQueryFragmentEncoding, encodeQuery, encodeFragment, reescapeHostDelimiters, isIPv4, nonSimpleDomain } = require_utils();
8582
+ var { normalizeIPv6, removeDotSegments, removeDotSegmentsRelative, recomposeAuthority, normalizePercentEncoding, normalizePathEncoding, serializePathEncoding, normalizeQueryFragmentEncoding, encodeQuery, encodeFragment, encodeHost, isIPv4, nonSimpleDomain } = require_utils();
8163
8583
  var { SCHEMES, getSchemeHandler } = require_schemes();
8164
8584
  var VALID_SCHEME = /^[A-Za-z][A-Za-z0-9+.-]*$/u;
8165
8585
  var MALFORMED_SCHEME_ERROR = "URI scheme is malformed.";
@@ -8197,21 +8617,36 @@ var require_fast_uri = /* @__PURE__ */ __commonJSMin(((exports, module) => {
8197
8617
  */
8198
8618
  function resolve(baseURI, relativeURI, options) {
8199
8619
  const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
8200
- const { parsed: baseParsed, malformedAuthorityOrPort: baseMalformed, malformedPercentEncoding: baseMalformedPercentEncoding, malformedSchemeSpecific: baseMalformedSchemeSpecific, malformedHost: baseMalformedHost, malformedScheme: baseMalformedScheme } = parseWithStatus(baseURI, schemelessOptions);
8201
- const { parsed: relativeParsed, malformedAuthorityOrPort: relativeMalformed, malformedPercentEncoding: relativeMalformedPercentEncoding, malformedSchemeSpecific: relativeMalformedSchemeSpecific, malformedHost: relativeMalformedHost, malformedScheme: relativeMalformedScheme } = parseWithStatus(relativeURI, schemelessOptions);
8202
- if (baseMalformed || relativeMalformed || baseMalformedPercentEncoding || relativeMalformedPercentEncoding || baseMalformedSchemeSpecific || relativeMalformedSchemeSpecific || baseMalformedHost || relativeMalformedHost || baseMalformedScheme || relativeMalformedScheme) throw new Error(baseParsed.error || relativeParsed.error || "URI is malformed.");
8620
+ const { parsed: baseParsed, malformedAuthorityOrPort: baseMalformed, malformedReferenceEdge: baseMalformedReferenceEdge, malformedPercentEncoding: baseMalformedPercentEncoding, malformedSchemeSpecific: baseMalformedSchemeSpecific, malformedHost: baseMalformedHost, malformedScheme: baseMalformedScheme } = parseWithStatus(baseURI, schemelessOptions);
8621
+ const { parsed: relativeParsed, malformedAuthorityOrPort: relativeMalformed, malformedReferenceEdge: relativeMalformedReferenceEdge, malformedPercentEncoding: relativeMalformedPercentEncoding, malformedSchemeSpecific: relativeMalformedSchemeSpecific, malformedHost: relativeMalformedHost, malformedScheme: relativeMalformedScheme } = parseWithStatus(relativeURI, schemelessOptions);
8622
+ if (baseMalformed || relativeMalformed || baseMalformedReferenceEdge || relativeMalformedReferenceEdge || baseMalformedPercentEncoding || relativeMalformedPercentEncoding || baseMalformedSchemeSpecific || relativeMalformedSchemeSpecific || baseMalformedHost || relativeMalformedHost || baseMalformedScheme || relativeMalformedScheme) throw new Error(baseParsed.error || relativeParsed.error || "URI is malformed.");
8203
8623
  const resolved = resolveComponent(baseParsed, relativeParsed, schemelessOptions, true);
8204
8624
  const resolvedSchemeHandler = getSchemeHandler(options && options.scheme || resolved.scheme);
8205
8625
  const resolvedHost = resolved.host;
8626
+ if ((resolved.scheme === "http" || resolved.scheme === "https") && !resolvedHost) throw new Error("HTTP URIs must have a host.");
8206
8627
  const resolvedHostIsIP = resolvedHost !== void 0 && resolvedHost !== "" && (isIPv4(resolvedHost) || normalizeIPv6(resolvedHost).isIPV6);
8207
8628
  if (hasForbiddenDomainHost(resolved, options || {}, resolvedSchemeHandler, resolvedHostIsIP)) throw new Error(MALFORMED_HOST_ERROR);
8208
8629
  canonicalizeHost(resolved, options || {}, resolvedSchemeHandler, resolvedHostIsIP);
8209
8630
  const encodedASCIIHost = resolvedHost && resolvedHost.indexOf("%") !== -1 && !/\P{ASCII}/u.test(resolvedHost);
8210
8631
  if (resolved.error && !encodedASCIIHost) throw new Error(resolved.error);
8211
8632
  schemelessOptions.skipEscape = true;
8633
+ if (resolvedSchemeHandler && resolvedSchemeHandler.absolutePath) schemelessOptions.absolutePath = true;
8212
8634
  return serialize(resolved, schemelessOptions);
8213
8635
  }
8214
8636
  /**
8637
+ * Copies a host component together with its parse-time zone identifier (if
8638
+ * any), so downstream recomposition does not re-derive an IPv6 zone from the
8639
+ * ambiguous single-"%" component form. The zone is validated on use by
8640
+ * `recomposeAuthority` rather than blindly trusted.
8641
+ *
8642
+ * @param {import('./types/index').URIComponent} target
8643
+ * @param {import('./types/index').URIComponent} source
8644
+ */
8645
+ function copyHost(target, source) {
8646
+ target.host = source.host;
8647
+ if (source.ipv6Zone !== void 0) target.ipv6Zone = source.ipv6Zone;
8648
+ }
8649
+ /**
8215
8650
  * @param {import ('./types/index').URIComponent} base
8216
8651
  * @param {import ('./types/index').URIComponent} relative
8217
8652
  * @param {import('./types/index').Options} [options]
@@ -8229,14 +8664,15 @@ var require_fast_uri = /* @__PURE__ */ __commonJSMin(((exports, module) => {
8229
8664
  if (!options.tolerant && relative.scheme) {
8230
8665
  target.scheme = relative.scheme;
8231
8666
  target.userinfo = relative.userinfo;
8232
- target.host = relative.host;
8667
+ copyHost(target, relative);
8233
8668
  target.port = relative.port;
8234
- target.path = removeDotSegments(relative.path || "");
8669
+ const relativeSchemeHandler = getSchemeHandler(relative.scheme);
8670
+ target.path = relativeSchemeHandler && relativeSchemeHandler.absolutePath ? relative.path || "" : removeDotSegments(relative.path || "");
8235
8671
  target.query = relative.query;
8236
8672
  } else {
8237
8673
  if (relative.userinfo !== void 0 || relative.host !== void 0 || relative.port !== void 0) {
8238
8674
  target.userinfo = relative.userinfo;
8239
- target.host = relative.host;
8675
+ copyHost(target, relative);
8240
8676
  target.port = relative.port;
8241
8677
  target.path = removeDotSegments(relative.path || "");
8242
8678
  target.query = relative.query;
@@ -8257,7 +8693,7 @@ var require_fast_uri = /* @__PURE__ */ __commonJSMin(((exports, module) => {
8257
8693
  target.query = relative.query;
8258
8694
  }
8259
8695
  target.userinfo = base.userinfo;
8260
- target.host = base.host;
8696
+ copyHost(target, base);
8261
8697
  target.port = base.port;
8262
8698
  }
8263
8699
  target.scheme = base.scheme;
@@ -8284,6 +8720,7 @@ var require_fast_uri = /* @__PURE__ */ __commonJSMin(((exports, module) => {
8284
8720
  function serialize(cmpts, opts) {
8285
8721
  const component = {
8286
8722
  host: cmpts.host,
8723
+ ipv6Zone: cmpts.ipv6Zone,
8287
8724
  scheme: cmpts.scheme,
8288
8725
  userinfo: cmpts.userinfo,
8289
8726
  port: cmpts.port,
@@ -8296,6 +8733,10 @@ var require_fast_uri = /* @__PURE__ */ __commonJSMin(((exports, module) => {
8296
8733
  reference: cmpts.reference,
8297
8734
  resourceName: cmpts.resourceName,
8298
8735
  secure: cmpts.secure,
8736
+ to: cmpts.to,
8737
+ subject: cmpts.subject,
8738
+ body: cmpts.body,
8739
+ headers: cmpts.headers,
8299
8740
  error: ""
8300
8741
  };
8301
8742
  const options = Object.assign({}, opts);
@@ -8314,7 +8755,7 @@ var require_fast_uri = /* @__PURE__ */ __commonJSMin(((exports, module) => {
8314
8755
  component.scheme = validateScheme(component.scheme);
8315
8756
  uriTokens.push(component.scheme, ":");
8316
8757
  }
8317
- const authority = recomposeAuthority(component);
8758
+ const authority = recomposeAuthority(component, options.unicodeSupport === true || Boolean(schemeHandler && schemeHandler.unicodeSupport));
8318
8759
  if (authority !== void 0) {
8319
8760
  if (options.reference !== "suffix") uriTokens.push("//");
8320
8761
  uriTokens.push(authority);
@@ -8387,11 +8828,12 @@ var require_fast_uri = /* @__PURE__ */ __commonJSMin(((exports, module) => {
8387
8828
  * @returns {boolean} whether host conversion failed
8388
8829
  */
8389
8830
  function canonicalizeHost(parsed, options, schemeHandler, isIP) {
8831
+ const bracketedIPLiteral = parsed.host && parsed.host[0] === "[" && parsed.host[parsed.host.length - 1] === "]";
8390
8832
  if (hasForbiddenDomainHost(parsed, options, schemeHandler, isIP)) {
8391
8833
  parsed.error = parsed.error || MALFORMED_HOST_ERROR;
8392
8834
  return true;
8393
8835
  }
8394
- if (!options.unicodeSupport && (!schemeHandler || !schemeHandler.unicodeSupport) && parsed.host && !isIPLiteral(parsed.host) && (options.domainHost || schemeHandler && schemeHandler.domainHost) && isIP === false && nonSimpleDomain(parsed.host)) {
8836
+ if (!options.unicodeSupport && (!schemeHandler || !schemeHandler.unicodeSupport) && parsed.host && !isIPLiteral(parsed.host) && (options.domainHost || schemeHandler && schemeHandler.domainHost) && isIP === false && !bracketedIPLiteral && nonSimpleDomain(parsed.host)) {
8395
8837
  let url;
8396
8838
  try {
8397
8839
  url = new URL("http://" + parsed.host);
@@ -8433,7 +8875,7 @@ var require_fast_uri = /* @__PURE__ */ __commonJSMin(((exports, module) => {
8433
8875
  /**
8434
8876
  * @param {string} uri
8435
8877
  * @param {import('./types/index').Options} [opts]
8436
- * @returns {{ parsed: import('./types/index').URIComponent, malformedAuthorityOrPort: boolean, malformedPercentEncoding: boolean, malformedSchemeSpecific: boolean, malformedHost: boolean, malformedScheme: boolean }}
8878
+ * @returns {{ parsed: import('./types/index').URIComponent, malformedAuthorityOrPort: boolean, malformedReferenceEdge: boolean, malformedPercentEncoding: boolean, malformedSchemeSpecific: boolean, malformedHost: boolean, malformedScheme: boolean }}
8437
8879
  */
8438
8880
  function parseWithStatus(uri, opts) {
8439
8881
  const options = Object.assign({}, opts);
@@ -8448,6 +8890,7 @@ var require_fast_uri = /* @__PURE__ */ __commonJSMin(((exports, module) => {
8448
8890
  fragment: void 0
8449
8891
  };
8450
8892
  let malformedAuthorityOrPort = false;
8893
+ const malformedReferenceEdge = uri.length !== 0 && (uri.charCodeAt(0) <= 32 || uri.charCodeAt(uri.length - 1) <= 32);
8451
8894
  let malformedPercentEncoding = false;
8452
8895
  let malformedSchemeSpecific = false;
8453
8896
  let malformedHost = false;
@@ -8477,6 +8920,7 @@ var require_fast_uri = /* @__PURE__ */ __commonJSMin(((exports, module) => {
8477
8920
  }
8478
8921
  }
8479
8922
  }
8923
+ if (malformedReferenceEdge) parsed.error = parsed.error || "URI must not contain leading or trailing C0 controls or spaces.";
8480
8924
  const matches = uri.match(URI_PARSE);
8481
8925
  if (matches) {
8482
8926
  parsed.scheme = matches[1];
@@ -8509,6 +8953,7 @@ var require_fast_uri = /* @__PURE__ */ __commonJSMin(((exports, module) => {
8509
8953
  isIP = ipv6result.isIPV6 || ipv6result.isIPVFuture === true;
8510
8954
  malformedIPLiteral = hasIPLiteralBracket && (!bracketedIPLiteral || ipv6result.error === true);
8511
8955
  parsed.host = isIP ? ipv6result.host : ipv6result.host.toLowerCase();
8956
+ if (isIP && ipv6result.isIPV6 === true && parsed.host.indexOf("%") !== -1) parsed.ipv6Zone = parsed.host.slice(parsed.host.indexOf("%") + 1);
8512
8957
  if (malformedIPLiteral) {
8513
8958
  parsed.error = parsed.error || MALFORMED_HOST_ERROR;
8514
8959
  malformedAuthorityOrPort = true;
@@ -8522,10 +8967,16 @@ var require_fast_uri = /* @__PURE__ */ __commonJSMin(((exports, module) => {
8522
8967
  if (options.reference && options.reference !== "suffix" && options.reference !== parsed.reference) parsed.error = parsed.error || "URI is not a " + options.reference + " reference.";
8523
8968
  const schemeHandler = getSchemeHandler(options.scheme || parsed.scheme);
8524
8969
  if (!malformedIPLiteral) malformedHost = canonicalizeHost(parsed, options, schemeHandler, isIP);
8525
- if (uri.indexOf("%") !== -1 && parsed.host !== void 0 && !malformedIPLiteral) {
8526
- let host = isIP ? parsed.host : normalizePercentEncoding(parsed.host, true);
8527
- if (!isIP) host = normalizePercentEncoding(host.toLowerCase());
8528
- parsed.host = isIP || options.scheme !== "null" ? reescapeHostDelimiters(host, isIP) : host;
8970
+ if (parsed.host !== void 0 && !malformedIPLiteral) {
8971
+ let host = parsed.host;
8972
+ if (uri.indexOf("%") !== -1 && !isIP) {
8973
+ host = normalizePercentEncoding(host, true);
8974
+ host = normalizePercentEncoding(host.toLowerCase());
8975
+ }
8976
+ if (options.scheme !== "null") {
8977
+ const allowNonAsciiHost = options.unicodeSupport === true || Boolean(schemeHandler && schemeHandler.unicodeSupport);
8978
+ parsed.host = encodeHost(host, isIP, allowNonAsciiHost);
8979
+ } else parsed.host = host;
8529
8980
  }
8530
8981
  if (!schemeHandler || schemeHandler && !schemeHandler.skipNormalize) {
8531
8982
  if (parsed.path) parsed.path = normalizePathEncoding(parsed.path);
@@ -8540,6 +8991,7 @@ var require_fast_uri = /* @__PURE__ */ __commonJSMin(((exports, module) => {
8540
8991
  return {
8541
8992
  parsed,
8542
8993
  malformedAuthorityOrPort,
8994
+ malformedReferenceEdge,
8543
8995
  malformedPercentEncoding,
8544
8996
  malformedSchemeSpecific,
8545
8997
  malformedHost,
@@ -8565,13 +9017,14 @@ var require_fast_uri = /* @__PURE__ */ __commonJSMin(((exports, module) => {
8565
9017
  /**
8566
9018
  * @param {string} uri
8567
9019
  * @param {import('./types/index').Options} [opts]
8568
- * @returns {{ normalized: string, malformedAuthorityOrPort: boolean, malformedPercentEncoding: boolean, malformedSchemeSpecific: boolean, malformedHost: boolean, malformedScheme: boolean }}
9020
+ * @returns {{ normalized: string, malformedAuthorityOrPort: boolean, malformedReferenceEdge: boolean, malformedPercentEncoding: boolean, malformedSchemeSpecific: boolean, malformedHost: boolean, malformedScheme: boolean }}
8569
9021
  */
8570
9022
  function normalizeStringWithStatus(uri, opts) {
8571
- const { parsed, malformedAuthorityOrPort, malformedPercentEncoding, malformedSchemeSpecific, malformedHost, malformedScheme } = parseWithStatus(uri, opts);
9023
+ const { parsed, malformedAuthorityOrPort, malformedReferenceEdge, malformedPercentEncoding, malformedSchemeSpecific, malformedHost, malformedScheme } = parseWithStatus(uri, opts);
8572
9024
  return {
8573
- normalized: malformedAuthorityOrPort || malformedPercentEncoding || malformedSchemeSpecific || malformedHost || malformedScheme ? uri : serialize(parsed, opts),
9025
+ normalized: malformedAuthorityOrPort || malformedReferenceEdge || malformedPercentEncoding || malformedSchemeSpecific || malformedHost || malformedScheme ? uri : serialize(parsed, opts),
8574
9026
  malformedAuthorityOrPort,
9027
+ malformedReferenceEdge,
8575
9028
  malformedPercentEncoding,
8576
9029
  malformedSchemeSpecific,
8577
9030
  malformedHost,
@@ -8591,8 +9044,8 @@ var require_fast_uri = /* @__PURE__ */ __commonJSMin(((exports, module) => {
8591
9044
  } catch {
8592
9045
  return;
8593
9046
  }
8594
- const { normalized, malformedAuthorityOrPort, malformedPercentEncoding, malformedSchemeSpecific, malformedHost, malformedScheme } = normalizeStringWithStatus(value, opts);
8595
- return malformedAuthorityOrPort || malformedPercentEncoding || malformedSchemeSpecific || malformedHost || malformedScheme ? void 0 : normalized;
9047
+ const { normalized, malformedAuthorityOrPort, malformedReferenceEdge, malformedPercentEncoding, malformedSchemeSpecific, malformedHost, malformedScheme } = normalizeStringWithStatus(value, opts);
9048
+ return malformedAuthorityOrPort || malformedReferenceEdge || malformedPercentEncoding || malformedSchemeSpecific || malformedHost || malformedScheme ? void 0 : normalized;
8596
9049
  }
8597
9050
  var fastUri = {
8598
9051
  SCHEMES,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubohiroya/turbowarp-cloudflare-worker",
3
- "version": "0.8.1",
3
+ "version": "0.9.1",
4
4
  "description": "Cloudflare Workers TypeScript generator and TurboWarp extension bridge for turbowarp-http-server.",
5
5
  "author": {
6
6
  "name": "Hiroya Kubo",
@@ -73,7 +73,7 @@
73
73
  },
74
74
  "dependencies": {
75
75
  "hono": "^4.10.7",
76
- "@kubohiroya/turbowarp-extension-data-editor": "^0.11.0"
76
+ "@kubohiroya/turbowarp-extension-data-editor": "^0.11.4"
77
77
  },
78
78
  "devDependencies": {
79
79
  "@cloudflare/workers-types": "^5.20260826.1",