@inerrata-corporation/errata 2.0.22-dev.4355 → 2.0.22-dev.4430

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.
@@ -3099,12 +3099,34 @@ var require_data = __commonJS({
3099
3099
  }
3100
3100
  });
3101
3101
 
3102
- // ../../node_modules/.pnpm/fast-uri@3.1.0/node_modules/fast-uri/lib/utils.js
3102
+ // ../../node_modules/.pnpm/fast-uri@3.1.8/node_modules/fast-uri/lib/utils.js
3103
3103
  var require_utils = __commonJS({
3104
- "../../node_modules/.pnpm/fast-uri@3.1.0/node_modules/fast-uri/lib/utils.js"(exports, module) {
3104
+ "../../node_modules/.pnpm/fast-uri@3.1.8/node_modules/fast-uri/lib/utils.js"(exports, module) {
3105
3105
  "use strict";
3106
3106
  var isUUID = RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu);
3107
3107
  var isIPv4 = RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u);
3108
+ var isPort = RegExp.prototype.test.bind(/^\d*$/u);
3109
+ var isHexPair = RegExp.prototype.test.bind(/^[\da-f]{2}$/iu);
3110
+ var isUnreserved = RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu);
3111
+ var isPathCharacter = RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:@/]$/u);
3112
+ var isQueryFragmentCharacter = RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:@/?]$/u);
3113
+ var isUserinfoCharacter = RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:]$/u);
3114
+ var BYTE_HEX = new Array(256);
3115
+ {
3116
+ const HEX_DIGITS = "0123456789ABCDEF";
3117
+ for (let i = 0; i < 256; i++) {
3118
+ BYTE_HEX[i] = "%" + HEX_DIGITS[i >> 4] + HEX_DIGITS[i & 15];
3119
+ }
3120
+ }
3121
+ function percentEncodeNonAscii(cp) {
3122
+ if (cp < 2048) {
3123
+ return BYTE_HEX[192 | cp >> 6] + BYTE_HEX[128 | cp & 63];
3124
+ }
3125
+ if (cp < 65536) {
3126
+ return BYTE_HEX[224 | cp >> 12] + BYTE_HEX[128 | cp >> 6 & 63] + BYTE_HEX[128 | cp & 63];
3127
+ }
3128
+ return BYTE_HEX[240 | cp >> 18] + BYTE_HEX[128 | cp >> 12 & 63] + BYTE_HEX[128 | cp >> 6 & 63] + BYTE_HEX[128 | cp & 63];
3129
+ }
3108
3130
  function stringArrayToHexStripped(input) {
3109
3131
  let acc = "";
3110
3132
  let code = 0;
@@ -3129,91 +3151,105 @@ var require_utils = __commonJS({
3129
3151
  }
3130
3152
  return acc;
3131
3153
  }
3154
+ var isHextet = RegExp.prototype.test.bind(/^[\dA-Fa-f]{1,4}$/);
3155
+ var isIPvFuture = RegExp.prototype.test.bind(/^[vV][\dA-Fa-f]+\.[A-Za-z\d\-._~!$&'()*+,;=:]+$/);
3156
+ var isZoneCharacter = RegExp.prototype.test.bind(/^[A-Za-z\d\-._~]$/);
3132
3157
  var nonSimpleDomain = RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);
3133
- function consumeIsZone(buffer) {
3134
- buffer.length = 0;
3135
- return true;
3136
- }
3137
- function consumeHextets(buffer, address, output) {
3138
- if (buffer.length) {
3139
- const hex3 = stringArrayToHexStripped(buffer);
3140
- if (hex3 !== "") {
3141
- address.push(hex3);
3142
- } else {
3143
- output.error = true;
3144
- return false;
3158
+ function isZoneIdentifier(zone) {
3159
+ if (zone.length === 0) return false;
3160
+ for (let i = 0; i < zone.length; i++) {
3161
+ if (isZoneCharacter(zone[i])) continue;
3162
+ if (zone[i] === "%" && i + 2 < zone.length && isHexPair(zone.slice(i + 1, i + 3))) {
3163
+ i += 2;
3164
+ continue;
3145
3165
  }
3146
- buffer.length = 0;
3166
+ return false;
3147
3167
  }
3148
3168
  return true;
3149
3169
  }
3150
- function getIPV6(input) {
3151
- let tokenCount = 0;
3152
- const output = { error: false, address: "", zone: "" };
3153
- const address = [];
3154
- const buffer = [];
3155
- let endipv6Encountered = false;
3156
- let endIpv6 = false;
3157
- let consume = consumeHextets;
3158
- for (let i = 0; i < input.length; i++) {
3159
- const cursor = input[i];
3160
- if (cursor === "[" || cursor === "]") {
3161
- continue;
3162
- }
3163
- if (cursor === ":") {
3164
- if (endipv6Encountered === true) {
3165
- endIpv6 = true;
3166
- }
3167
- if (!consume(buffer, address, output)) {
3168
- break;
3169
- }
3170
- if (++tokenCount > 7) {
3171
- output.error = true;
3172
- break;
3173
- }
3174
- if (i > 0 && input[i - 1] === ":") {
3175
- endipv6Encountered = true;
3176
- }
3177
- address.push(":");
3178
- continue;
3179
- } else if (cursor === "%") {
3180
- if (!consume(buffer, address, output)) {
3181
- break;
3170
+ function compressIPv6ZeroRun(hextets) {
3171
+ let bestStart = -1;
3172
+ let bestLength = 0;
3173
+ let runStart = -1;
3174
+ let runLength = 0;
3175
+ for (let i = 0; i < hextets.length; i++) {
3176
+ if (hextets[i] === "0") {
3177
+ if (runStart === -1) runStart = i;
3178
+ runLength++;
3179
+ if (runLength > bestLength) {
3180
+ bestLength = runLength;
3181
+ bestStart = runStart;
3182
3182
  }
3183
- consume = consumeIsZone;
3184
3183
  } else {
3185
- buffer.push(cursor);
3184
+ runStart = -1;
3185
+ runLength = 0;
3186
+ }
3187
+ }
3188
+ if (bestLength < 2) return hextets.join(":");
3189
+ const head = hextets.slice(0, bestStart).join(":");
3190
+ const tail = hextets.slice(bestStart + bestLength).join(":");
3191
+ return head + "::" + tail;
3192
+ }
3193
+ function normalizeIPv6Address(input) {
3194
+ const compression = input.indexOf("::");
3195
+ if (compression !== -1 && input.indexOf("::", compression + 1) !== -1) return void 0;
3196
+ const left = compression === -1 ? input.split(":") : input.slice(0, compression).split(":");
3197
+ const right = compression === -1 ? [] : input.slice(compression + 2).split(":");
3198
+ if (compression !== -1) {
3199
+ if (left.length === 1 && left[0] === "") left.length = 0;
3200
+ if (right.length === 1 && right[0] === "") right.length = 0;
3201
+ }
3202
+ const parts = left.concat(right);
3203
+ let hextetCount = 0;
3204
+ for (let i = 0; i < parts.length; i++) {
3205
+ const part = parts[i];
3206
+ if (part === "") return void 0;
3207
+ if (part.indexOf(".") !== -1) {
3208
+ if (i !== parts.length - 1 || compression !== -1 && right.length === 0 || !isIPv4(part)) return void 0;
3209
+ hextetCount += 2;
3186
3210
  continue;
3187
3211
  }
3212
+ if (!isHextet(part)) return void 0;
3213
+ parts[i] = parseInt(part, 16).toString(16);
3214
+ hextetCount++;
3188
3215
  }
3189
- if (buffer.length) {
3190
- if (consume === consumeIsZone) {
3191
- output.zone = buffer.join("");
3192
- } else if (endIpv6) {
3193
- address.push(buffer.join(""));
3194
- } else {
3195
- address.push(stringArrayToHexStripped(buffer));
3196
- }
3216
+ if (compression === -1) {
3217
+ if (hextetCount !== 8) return void 0;
3218
+ return compressIPv6ZeroRun(parts);
3197
3219
  }
3198
- output.address = address.join("");
3199
- return output;
3220
+ if (hextetCount >= 8) return void 0;
3221
+ const expanded = parts.slice(0, left.length);
3222
+ for (let i = hextetCount; i < 8; i++) expanded.push("0");
3223
+ for (let i = left.length; i < parts.length; i++) expanded.push(parts[i]);
3224
+ return compressIPv6ZeroRun(expanded);
3200
3225
  }
3201
3226
  function normalizeIPv6(host) {
3202
- if (findToken(host, ":") < 2) {
3203
- return { host, isIPV6: false };
3204
- }
3205
- const ipv63 = getIPV6(host);
3206
- if (!ipv63.error) {
3207
- let newHost = ipv63.address;
3208
- let escapedHost = ipv63.address;
3209
- if (ipv63.zone) {
3210
- newHost += "%" + ipv63.zone;
3211
- escapedHost += "%25" + ipv63.zone;
3212
- }
3213
- return { host: newHost, isIPV6: true, escapedHost };
3214
- } else {
3215
- return { host, isIPV6: false };
3216
- }
3227
+ const bracketed = host[0] === "[" && host[host.length - 1] === "]";
3228
+ const hasBracket = host[0] === "[" || host[host.length - 1] === "]";
3229
+ if (hasBracket && !bracketed) return { host, isIPV6: false, error: true };
3230
+ let input = bracketed ? host.slice(1, -1) : host;
3231
+ if (bracketed && isIPvFuture(input)) {
3232
+ input = input.toLowerCase();
3233
+ return { host: `[${input}]`, escapedHost: input, isIPV6: false, isIPVFuture: true };
3234
+ }
3235
+ if (findToken(input, ":") < 2) {
3236
+ return { host, isIPV6: false, error: bracketed };
3237
+ }
3238
+ let zoneIdentifier = "";
3239
+ const zoneSeparator = input.indexOf("%");
3240
+ if (zoneSeparator !== -1) {
3241
+ const separatorLength = input.slice(zoneSeparator, zoneSeparator + 3).toLowerCase() === "%25" ? 3 : 1;
3242
+ zoneIdentifier = input.slice(zoneSeparator + separatorLength);
3243
+ if (!isZoneIdentifier(zoneIdentifier)) return { host, isIPV6: false, error: true };
3244
+ input = input.slice(0, zoneSeparator);
3245
+ }
3246
+ const address = normalizeIPv6Address(input);
3247
+ if (address === void 0) return { host, isIPV6: false, error: true };
3248
+ return {
3249
+ host: address + (zoneIdentifier ? "%" + zoneIdentifier : ""),
3250
+ escapedHost: address + (zoneIdentifier ? "%25" + zoneIdentifier : ""),
3251
+ isIPV6: true
3252
+ };
3217
3253
  }
3218
3254
  function findToken(str, token) {
3219
3255
  let ind = 0;
@@ -3297,56 +3333,265 @@ var require_utils = __commonJS({
3297
3333
  }
3298
3334
  return output.join("");
3299
3335
  }
3300
- function normalizeComponentEncoding(component, esc2) {
3301
- const func = esc2 !== true ? escape : unescape;
3302
- if (component.scheme !== void 0) {
3303
- component.scheme = func(component.scheme);
3336
+ var HOST_DELIMS = { "@": "%40", "/": "%2F", "?": "%3F", "#": "%23", ":": "%3A" };
3337
+ var HOST_DELIM_RE = /[@/?#:]/g;
3338
+ var HOST_DELIM_NO_COLON_RE = /[@/?#]/g;
3339
+ function reescapeHostDelimiters(host, isIP) {
3340
+ const re = isIP ? HOST_DELIM_NO_COLON_RE : HOST_DELIM_RE;
3341
+ re.lastIndex = 0;
3342
+ return host.replace(re, (ch) => HOST_DELIMS[ch]);
3343
+ }
3344
+ function normalizePercentEncoding(input, decodeUnreserved = false) {
3345
+ if (input.indexOf("%") === -1) {
3346
+ return input;
3304
3347
  }
3305
- if (component.userinfo !== void 0) {
3306
- component.userinfo = func(component.userinfo);
3348
+ let output = "";
3349
+ for (let i = 0; i < input.length; i++) {
3350
+ if (input[i] === "%" && i + 2 < input.length) {
3351
+ const hex3 = input.slice(i + 1, i + 3);
3352
+ if (isHexPair(hex3)) {
3353
+ const normalizedHex = hex3.toUpperCase();
3354
+ const decoded = String.fromCharCode(parseInt(normalizedHex, 16));
3355
+ if (decodeUnreserved && isUnreserved(decoded)) {
3356
+ output += decoded;
3357
+ } else {
3358
+ output += "%" + normalizedHex;
3359
+ }
3360
+ i += 2;
3361
+ continue;
3362
+ }
3363
+ }
3364
+ output += input[i];
3307
3365
  }
3308
- if (component.host !== void 0) {
3309
- component.host = func(component.host);
3366
+ return output;
3367
+ }
3368
+ function normalizePathEncoding(input) {
3369
+ let output = "";
3370
+ for (let i = 0; i < input.length; i++) {
3371
+ const ch = input[i];
3372
+ if (ch === "%" && i + 2 < input.length) {
3373
+ const hex3 = input.slice(i + 1, i + 3);
3374
+ if (isHexPair(hex3)) {
3375
+ const normalizedHex = hex3.toUpperCase();
3376
+ const decoded = String.fromCharCode(parseInt(normalizedHex, 16));
3377
+ if (decoded !== "." && isUnreserved(decoded)) {
3378
+ output += decoded;
3379
+ } else {
3380
+ output += "%" + normalizedHex;
3381
+ }
3382
+ i += 2;
3383
+ continue;
3384
+ }
3385
+ }
3386
+ if (isPathCharacter(ch)) {
3387
+ output += ch;
3388
+ } else {
3389
+ const code = input.charCodeAt(i);
3390
+ if (code < 128) {
3391
+ output += isEscapeSafe(code) ? ch : BYTE_HEX[code];
3392
+ } else if (code < 55296 || code > 57343) {
3393
+ output += percentEncodeNonAscii(code);
3394
+ } else if (code <= 56319 && i + 1 < input.length) {
3395
+ const low = input.charCodeAt(i + 1);
3396
+ if (low >= 56320 && low <= 57343) {
3397
+ output += percentEncodeNonAscii(65536 + (code - 55296 << 10) + (low - 56320));
3398
+ i++;
3399
+ } else {
3400
+ output += percentEncodeNonAscii(65533);
3401
+ }
3402
+ } else {
3403
+ output += percentEncodeNonAscii(65533);
3404
+ }
3405
+ }
3310
3406
  }
3311
- if (component.path !== void 0) {
3312
- component.path = func(component.path);
3407
+ return output;
3408
+ }
3409
+ function serializePathEncoding(input, pathNoScheme = false) {
3410
+ let output = "";
3411
+ let firstSegment = pathNoScheme && input[0] !== "/";
3412
+ for (let i = 0; i < input.length; i++) {
3413
+ const ch = input[i];
3414
+ if (ch === "%" && i + 2 < input.length) {
3415
+ const hex3 = input.slice(i + 1, i + 3);
3416
+ if (isHexPair(hex3)) {
3417
+ output += "%" + hex3.toUpperCase();
3418
+ i += 2;
3419
+ continue;
3420
+ }
3421
+ }
3422
+ if (ch === "/") {
3423
+ firstSegment = false;
3424
+ }
3425
+ if (isPathCharacter(ch) && (ch !== ":" || !firstSegment)) {
3426
+ output += ch;
3427
+ } else {
3428
+ const code = input.charCodeAt(i);
3429
+ if (code < 128) {
3430
+ output += BYTE_HEX[code];
3431
+ } else if (code < 55296 || code > 57343) {
3432
+ output += percentEncodeNonAscii(code);
3433
+ } else if (code <= 56319 && i + 1 < input.length) {
3434
+ const low = input.charCodeAt(i + 1);
3435
+ if (low >= 56320 && low <= 57343) {
3436
+ output += percentEncodeNonAscii(65536 + (code - 55296 << 10) + (low - 56320));
3437
+ i++;
3438
+ } else {
3439
+ output += percentEncodeNonAscii(65533);
3440
+ }
3441
+ } else {
3442
+ output += percentEncodeNonAscii(65533);
3443
+ }
3444
+ }
3313
3445
  }
3314
- if (component.query !== void 0) {
3315
- component.query = func(component.query);
3446
+ return output;
3447
+ }
3448
+ function encodeComponent(input, isAllowed) {
3449
+ let output = "";
3450
+ for (let i = 0; i < input.length; i++) {
3451
+ const ch = input[i];
3452
+ if (ch === "%" && i + 2 < input.length) {
3453
+ const hex3 = input.slice(i + 1, i + 3);
3454
+ if (isHexPair(hex3)) {
3455
+ output += "%" + hex3.toUpperCase();
3456
+ i += 2;
3457
+ continue;
3458
+ }
3459
+ }
3460
+ if (isAllowed(ch)) {
3461
+ output += ch;
3462
+ } else {
3463
+ const code = input.charCodeAt(i);
3464
+ if (code < 128) {
3465
+ output += BYTE_HEX[code];
3466
+ } else if (code < 55296 || code > 57343) {
3467
+ output += percentEncodeNonAscii(code);
3468
+ } else if (code <= 56319 && i + 1 < input.length) {
3469
+ const low = input.charCodeAt(i + 1);
3470
+ if (low >= 56320 && low <= 57343) {
3471
+ output += percentEncodeNonAscii(65536 + (code - 55296 << 10) + (low - 56320));
3472
+ i++;
3473
+ } else {
3474
+ output += percentEncodeNonAscii(65533);
3475
+ }
3476
+ } else {
3477
+ output += percentEncodeNonAscii(65533);
3478
+ }
3479
+ }
3316
3480
  }
3317
- if (component.fragment !== void 0) {
3318
- component.fragment = func(component.fragment);
3481
+ return output;
3482
+ }
3483
+ function encodeUserinfo(input) {
3484
+ return encodeComponent(input, isUserinfoCharacter);
3485
+ }
3486
+ function encodeQuery(input) {
3487
+ return encodeComponent(input, isQueryFragmentCharacter);
3488
+ }
3489
+ function encodeFragment(input) {
3490
+ return encodeComponent(input, isQueryFragmentCharacter);
3491
+ }
3492
+ function isEscapeSafe(cp) {
3493
+ 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;
3494
+ }
3495
+ function normalizeQueryFragmentEncoding(input) {
3496
+ let output = "";
3497
+ for (let i = 0; i < input.length; i++) {
3498
+ const ch = input[i];
3499
+ if (ch === "%" && i + 2 < input.length) {
3500
+ const hex3 = input.slice(i + 1, i + 3);
3501
+ if (isHexPair(hex3)) {
3502
+ const normalizedHex = hex3.toUpperCase();
3503
+ const decoded = String.fromCharCode(parseInt(normalizedHex, 16));
3504
+ if (isUnreserved(decoded)) {
3505
+ output += decoded;
3506
+ } else {
3507
+ output += "%" + normalizedHex;
3508
+ }
3509
+ i += 2;
3510
+ continue;
3511
+ }
3512
+ }
3513
+ if (isQueryFragmentCharacter(ch)) {
3514
+ output += ch;
3515
+ } else {
3516
+ const code = input.charCodeAt(i);
3517
+ if (code < 128) {
3518
+ output += isEscapeSafe(code) ? ch : BYTE_HEX[code];
3519
+ } else if (code < 55296 || code > 57343) {
3520
+ output += percentEncodeNonAscii(code);
3521
+ } else if (code <= 56319 && i + 1 < input.length) {
3522
+ const low = input.charCodeAt(i + 1);
3523
+ if (low >= 56320 && low <= 57343) {
3524
+ output += percentEncodeNonAscii(65536 + (code - 55296 << 10) + (low - 56320));
3525
+ i++;
3526
+ } else {
3527
+ output += percentEncodeNonAscii(65533);
3528
+ }
3529
+ } else {
3530
+ output += percentEncodeNonAscii(65533);
3531
+ }
3532
+ }
3319
3533
  }
3320
- return component;
3534
+ return output;
3535
+ }
3536
+ function escapePreservingEscapes(input) {
3537
+ let output = "";
3538
+ for (let i = 0; i < input.length; i++) {
3539
+ if (input[i] === "%" && i + 2 < input.length) {
3540
+ const hex3 = input.slice(i + 1, i + 3);
3541
+ if (isHexPair(hex3)) {
3542
+ output += "%" + hex3.toUpperCase();
3543
+ i += 2;
3544
+ continue;
3545
+ }
3546
+ }
3547
+ output += escape(input[i]);
3548
+ }
3549
+ return output;
3321
3550
  }
3322
3551
  function recomposeAuthority(component) {
3323
3552
  const uriTokens = [];
3324
3553
  if (component.userinfo !== void 0) {
3325
- uriTokens.push(component.userinfo);
3554
+ uriTokens.push(encodeUserinfo(component.userinfo));
3326
3555
  uriTokens.push("@");
3327
3556
  }
3328
3557
  if (component.host !== void 0) {
3329
- let host = unescape(component.host);
3558
+ let host = component.host;
3330
3559
  if (!isIPv4(host)) {
3331
- const ipV6res = normalizeIPv6(host);
3332
- if (ipV6res.isIPV6 === true) {
3560
+ let ipV6res = normalizeIPv6(host);
3561
+ if (ipV6res.isIPV6 !== true && ipV6res.isIPVFuture !== true) {
3562
+ host = normalizePercentEncoding(host, true);
3563
+ ipV6res = normalizeIPv6(host);
3564
+ }
3565
+ if (ipV6res.isIPV6 === true || ipV6res.isIPVFuture === true) {
3333
3566
  host = `[${ipV6res.escapedHost}]`;
3334
3567
  } else {
3335
- host = component.host;
3568
+ host = reescapeHostDelimiters(host, false);
3336
3569
  }
3337
3570
  }
3338
3571
  uriTokens.push(host);
3339
3572
  }
3340
3573
  if (typeof component.port === "number" || typeof component.port === "string") {
3574
+ const port = String(component.port);
3575
+ if (!isPort(port)) {
3576
+ throw new TypeError("URI port is malformed.");
3577
+ }
3341
3578
  uriTokens.push(":");
3342
- uriTokens.push(String(component.port));
3579
+ uriTokens.push(port);
3343
3580
  }
3344
3581
  return uriTokens.length ? uriTokens.join("") : void 0;
3345
3582
  }
3346
3583
  module.exports = {
3347
3584
  nonSimpleDomain,
3348
3585
  recomposeAuthority,
3349
- normalizeComponentEncoding,
3586
+ reescapeHostDelimiters,
3587
+ normalizePercentEncoding,
3588
+ normalizePathEncoding,
3589
+ serializePathEncoding,
3590
+ normalizeQueryFragmentEncoding,
3591
+ encodeUserinfo,
3592
+ encodeQuery,
3593
+ encodeFragment,
3594
+ escapePreservingEscapes,
3350
3595
  removeDotSegments,
3351
3596
  isIPv4,
3352
3597
  isUUID,
@@ -3356,12 +3601,12 @@ var require_utils = __commonJS({
3356
3601
  }
3357
3602
  });
3358
3603
 
3359
- // ../../node_modules/.pnpm/fast-uri@3.1.0/node_modules/fast-uri/lib/schemes.js
3604
+ // ../../node_modules/.pnpm/fast-uri@3.1.8/node_modules/fast-uri/lib/schemes.js
3360
3605
  var require_schemes = __commonJS({
3361
- "../../node_modules/.pnpm/fast-uri@3.1.0/node_modules/fast-uri/lib/schemes.js"(exports, module) {
3606
+ "../../node_modules/.pnpm/fast-uri@3.1.8/node_modules/fast-uri/lib/schemes.js"(exports, module) {
3362
3607
  "use strict";
3363
3608
  var { isUUID } = require_utils();
3364
- var URN_REG = /([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu;
3609
+ var URN_REG = /^([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-./:;=@]|%[\da-f]{2})+)$/iu;
3365
3610
  var supportedSchemeNames = (
3366
3611
  /** @type {const} */
3367
3612
  [
@@ -3422,9 +3667,10 @@ var require_schemes = __commonJS({
3422
3667
  wsComponent.secure = void 0;
3423
3668
  }
3424
3669
  if (wsComponent.resourceName) {
3425
- const [path, query] = wsComponent.resourceName.split("?");
3670
+ const queryIndex = wsComponent.resourceName.indexOf("?");
3671
+ const path = queryIndex === -1 ? wsComponent.resourceName : wsComponent.resourceName.slice(0, queryIndex);
3426
3672
  wsComponent.path = path && path !== "/" ? path : void 0;
3427
- wsComponent.query = query;
3673
+ wsComponent.query = queryIndex === -1 ? void 0 : wsComponent.resourceName.slice(queryIndex + 1);
3428
3674
  wsComponent.resourceName = void 0;
3429
3675
  }
3430
3676
  wsComponent.fragment = void 0;
@@ -3436,7 +3682,7 @@ var require_schemes = __commonJS({
3436
3682
  return urnComponent;
3437
3683
  }
3438
3684
  const matches = urnComponent.path.match(URN_REG);
3439
- if (matches) {
3685
+ if (matches && matches[0] === urnComponent.path) {
3440
3686
  const scheme = options.scheme || urnComponent.scheme || "urn";
3441
3687
  urnComponent.nid = matches[1].toLowerCase();
3442
3688
  urnComponent.nss = matches[2];
@@ -3566,16 +3812,25 @@ var require_schemes = __commonJS({
3566
3812
  }
3567
3813
  });
3568
3814
 
3569
- // ../../node_modules/.pnpm/fast-uri@3.1.0/node_modules/fast-uri/index.js
3815
+ // ../../node_modules/.pnpm/fast-uri@3.1.8/node_modules/fast-uri/index.js
3570
3816
  var require_fast_uri = __commonJS({
3571
- "../../node_modules/.pnpm/fast-uri@3.1.0/node_modules/fast-uri/index.js"(exports, module) {
3817
+ "../../node_modules/.pnpm/fast-uri@3.1.8/node_modules/fast-uri/index.js"(exports, module) {
3572
3818
  "use strict";
3573
- var { normalizeIPv6, removeDotSegments, recomposeAuthority, normalizeComponentEncoding, isIPv4, nonSimpleDomain } = require_utils();
3819
+ var { normalizeIPv6, removeDotSegments, recomposeAuthority, normalizePercentEncoding, normalizePathEncoding, serializePathEncoding, normalizeQueryFragmentEncoding, encodeQuery, encodeFragment, reescapeHostDelimiters, isIPv4, nonSimpleDomain } = require_utils();
3574
3820
  var { SCHEMES, getSchemeHandler } = require_schemes();
3821
+ var VALID_SCHEME = /^[A-Za-z][A-Za-z0-9+.-]*$/u;
3822
+ var MALFORMED_SCHEME_ERROR = "URI scheme is malformed.";
3823
+ function decodeValidScheme(scheme) {
3824
+ const decodedScheme = unescape(String(scheme));
3825
+ if (!VALID_SCHEME.test(decodedScheme)) {
3826
+ throw new TypeError(MALFORMED_SCHEME_ERROR);
3827
+ }
3828
+ return decodedScheme;
3829
+ }
3575
3830
  function normalize(uri2, options) {
3576
3831
  if (typeof uri2 === "string") {
3577
3832
  uri2 = /** @type {T} */
3578
- serialize(parse3(uri2, options), options);
3833
+ normalizeString(uri2, options);
3579
3834
  } else if (typeof uri2 === "object") {
3580
3835
  uri2 = /** @type {T} */
3581
3836
  parse3(serialize(uri2, options), options);
@@ -3584,7 +3839,34 @@ var require_fast_uri = __commonJS({
3584
3839
  }
3585
3840
  function resolve3(baseURI, relativeURI, options) {
3586
3841
  const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
3587
- const resolved = resolveComponent(parse3(baseURI, schemelessOptions), parse3(relativeURI, schemelessOptions), schemelessOptions, true);
3842
+ const {
3843
+ parsed: baseParsed,
3844
+ malformedAuthorityOrPort: baseMalformed,
3845
+ malformedPercentEncoding: baseMalformedPercentEncoding,
3846
+ malformedSchemeSpecific: baseMalformedSchemeSpecific,
3847
+ malformedHost: baseMalformedHost,
3848
+ malformedScheme: baseMalformedScheme
3849
+ } = parseWithStatus(baseURI, schemelessOptions);
3850
+ const {
3851
+ parsed: relativeParsed,
3852
+ malformedAuthorityOrPort: relativeMalformed,
3853
+ malformedPercentEncoding: relativeMalformedPercentEncoding,
3854
+ malformedSchemeSpecific: relativeMalformedSchemeSpecific,
3855
+ malformedHost: relativeMalformedHost,
3856
+ malformedScheme: relativeMalformedScheme
3857
+ } = parseWithStatus(relativeURI, schemelessOptions);
3858
+ if (baseMalformed || relativeMalformed || baseMalformedPercentEncoding || relativeMalformedPercentEncoding || baseMalformedSchemeSpecific || relativeMalformedSchemeSpecific || baseMalformedHost || relativeMalformedHost || baseMalformedScheme || relativeMalformedScheme) {
3859
+ throw new Error(baseParsed.error || relativeParsed.error || "URI is malformed.");
3860
+ }
3861
+ const resolved = resolveComponent(baseParsed, relativeParsed, schemelessOptions, true);
3862
+ const resolvedSchemeHandler = getSchemeHandler(options && options.scheme || resolved.scheme);
3863
+ const resolvedHost = resolved.host;
3864
+ const resolvedHostIsIP = resolvedHost !== void 0 && resolvedHost !== "" && (isIPv4(resolvedHost) || normalizeIPv6(resolvedHost).isIPV6);
3865
+ canonicalizeHost(resolved, options || {}, resolvedSchemeHandler, resolvedHostIsIP);
3866
+ const encodedASCIIHost = resolvedHost && resolvedHost.indexOf("%") !== -1 && !new RegExp("\\P{ASCII}", "u").test(resolvedHost);
3867
+ if (resolved.error && !encodedASCIIHost) {
3868
+ throw new Error(resolved.error);
3869
+ }
3588
3870
  schemelessOptions.skipEscape = true;
3589
3871
  return serialize(resolved, schemelessOptions);
3590
3872
  }
@@ -3642,19 +3924,9 @@ var require_fast_uri = __commonJS({
3642
3924
  return target;
3643
3925
  }
3644
3926
  function equal(uriA, uriB, options) {
3645
- if (typeof uriA === "string") {
3646
- uriA = unescape(uriA);
3647
- uriA = serialize(normalizeComponentEncoding(parse3(uriA, options), true), { ...options, skipEscape: true });
3648
- } else if (typeof uriA === "object") {
3649
- uriA = serialize(normalizeComponentEncoding(uriA, true), { ...options, skipEscape: true });
3650
- }
3651
- if (typeof uriB === "string") {
3652
- uriB = unescape(uriB);
3653
- uriB = serialize(normalizeComponentEncoding(parse3(uriB, options), true), { ...options, skipEscape: true });
3654
- } else if (typeof uriB === "object") {
3655
- uriB = serialize(normalizeComponentEncoding(uriB, true), { ...options, skipEscape: true });
3656
- }
3657
- return uriA.toLowerCase() === uriB.toLowerCase();
3927
+ const normalizedA = normalizeComparableURI(uriA, options);
3928
+ const normalizedB = normalizeComparableURI(uriB, options);
3929
+ return normalizedA !== void 0 && normalizedB !== void 0 && normalizedA === normalizedB;
3658
3930
  }
3659
3931
  function serialize(cmpts, opts) {
3660
3932
  const component = {
@@ -3675,19 +3947,22 @@ var require_fast_uri = __commonJS({
3675
3947
  };
3676
3948
  const options = Object.assign({}, opts);
3677
3949
  const uriTokens = [];
3950
+ if (component.scheme) {
3951
+ component.scheme = decodeValidScheme(component.scheme);
3952
+ }
3678
3953
  const schemeHandler = getSchemeHandler(options.scheme || component.scheme);
3679
3954
  if (schemeHandler && schemeHandler.serialize) schemeHandler.serialize(component, options);
3955
+ const hasAuthority = component.userinfo !== void 0 || component.host !== void 0 || component.port !== void 0;
3956
+ const pathNoScheme = !options.skipEscape && component.scheme === void 0 && !hasAuthority;
3680
3957
  if (component.path !== void 0) {
3681
3958
  if (!options.skipEscape) {
3682
- component.path = escape(component.path);
3683
- if (component.scheme !== void 0) {
3684
- component.path = component.path.split("%3A").join(":");
3685
- }
3959
+ component.path = serializePathEncoding(component.path, pathNoScheme);
3686
3960
  } else {
3687
- component.path = unescape(component.path);
3961
+ component.path = normalizePercentEncoding(component.path);
3688
3962
  }
3689
3963
  }
3690
3964
  if (options.reference !== "suffix" && component.scheme) {
3965
+ component.scheme = decodeValidScheme(component.scheme);
3691
3966
  uriTokens.push(component.scheme, ":");
3692
3967
  }
3693
3968
  const authority = recomposeAuthority(component);
@@ -3705,21 +3980,64 @@ var require_fast_uri = __commonJS({
3705
3980
  if (!options.absolutePath && (!schemeHandler || !schemeHandler.absolutePath)) {
3706
3981
  s = removeDotSegments(s);
3707
3982
  }
3983
+ if (pathNoScheme) {
3984
+ s = serializePathEncoding(s, true);
3985
+ }
3708
3986
  if (authority === void 0 && s[0] === "/" && s[1] === "/") {
3709
3987
  s = "/%2F" + s.slice(2);
3710
3988
  }
3711
3989
  uriTokens.push(s);
3712
3990
  }
3713
3991
  if (component.query !== void 0) {
3714
- uriTokens.push("?", component.query);
3992
+ uriTokens.push("?", encodeQuery(component.query));
3715
3993
  }
3716
3994
  if (component.fragment !== void 0) {
3717
- uriTokens.push("#", component.fragment);
3995
+ uriTokens.push("#", encodeFragment(component.fragment));
3718
3996
  }
3719
3997
  return uriTokens.join("");
3720
3998
  }
3721
3999
  var URI_PARSE = /^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;
3722
- function parse3(uri2, opts) {
4000
+ var AUTHORITY_PREFIX = /^(?:[^#/:?]+:)?\/\/([^/?#]*)/;
4001
+ var AUTHORITY_INTRODUCER_REGION = /^(?:[^#/:?]+:)?([/\\\t\n\r]*)/;
4002
+ function getParseError(parsed, matches) {
4003
+ if (matches[2] !== void 0 && parsed.path && parsed.path[0] !== "/") {
4004
+ return 'URI path must start with "/" when authority is present.';
4005
+ }
4006
+ if (typeof parsed.port === "number" && (parsed.port < 0 || parsed.port > 65535)) {
4007
+ return "URI port is malformed.";
4008
+ }
4009
+ return void 0;
4010
+ }
4011
+ function hasMalformedPercentEncoding(component) {
4012
+ if (component === void 0) return false;
4013
+ let percent = component.indexOf("%");
4014
+ while (percent !== -1) {
4015
+ if (percent + 2 >= component.length || !/^[\da-f]{2}$/iu.test(component.slice(percent + 1, percent + 3))) {
4016
+ return true;
4017
+ }
4018
+ percent = component.indexOf("%", percent + 3);
4019
+ }
4020
+ return false;
4021
+ }
4022
+ function isIPLiteral(host) {
4023
+ return host[0] === "[" && host[host.length - 1] === "]";
4024
+ }
4025
+ function hasMalformedComponentPercentEncoding(matches) {
4026
+ const host = matches[4];
4027
+ return hasMalformedPercentEncoding(matches[3]) || host !== void 0 && !isIPLiteral(host) && hasMalformedPercentEncoding(host) || hasMalformedPercentEncoding(matches[6]) || hasMalformedPercentEncoding(matches[7]) || hasMalformedPercentEncoding(matches[8]);
4028
+ }
4029
+ function canonicalizeHost(parsed, options, schemeHandler, isIP) {
4030
+ if (!options.unicodeSupport && (!schemeHandler || !schemeHandler.unicodeSupport) && parsed.host && !isIPLiteral(parsed.host) && (options.domainHost || schemeHandler && schemeHandler.domainHost) && isIP === false && nonSimpleDomain(parsed.host)) {
4031
+ try {
4032
+ parsed.host = new URL("http://" + parsed.host).hostname;
4033
+ } catch (e) {
4034
+ parsed.error = parsed.error || "Host's domain name can not be converted to ASCII: " + e;
4035
+ return true;
4036
+ }
4037
+ }
4038
+ return false;
4039
+ }
4040
+ function parseWithStatus(uri2, opts) {
3723
4041
  const options = Object.assign({}, opts);
3724
4042
  const parsed = {
3725
4043
  scheme: void 0,
@@ -3730,6 +4048,12 @@ var require_fast_uri = __commonJS({
3730
4048
  query: void 0,
3731
4049
  fragment: void 0
3732
4050
  };
4051
+ let malformedAuthorityOrPort = false;
4052
+ let malformedPercentEncoding = false;
4053
+ let malformedSchemeSpecific = false;
4054
+ let malformedHost = false;
4055
+ let malformedIPLiteral = false;
4056
+ let malformedScheme = false;
3733
4057
  let isIP = false;
3734
4058
  if (options.reference === "suffix") {
3735
4059
  if (options.scheme) {
@@ -3738,6 +4062,25 @@ var require_fast_uri = __commonJS({
3738
4062
  uri2 = "//" + uri2;
3739
4063
  }
3740
4064
  }
4065
+ const authorityMatch = uri2.match(AUTHORITY_PREFIX);
4066
+ if (authorityMatch !== null && authorityMatch[1].indexOf("\\") !== -1) {
4067
+ parsed.error = "URI authority must not contain a literal backslash.";
4068
+ malformedAuthorityOrPort = true;
4069
+ }
4070
+ const introducerMatch = uri2.match(AUTHORITY_INTRODUCER_REGION);
4071
+ if (introducerMatch !== null) {
4072
+ const region = introducerMatch[1];
4073
+ const normalizedRegion = region.replace(/[\t\n\r]/g, "");
4074
+ if (normalizedRegion.length >= 2) {
4075
+ if (normalizedRegion.slice(0, 2) !== "//") {
4076
+ parsed.error = parsed.error || "URI authority must not contain a literal backslash.";
4077
+ malformedAuthorityOrPort = true;
4078
+ } else if (region.length !== normalizedRegion.length) {
4079
+ parsed.error = parsed.error || "URI authority introducer must not contain whitespace.";
4080
+ malformedAuthorityOrPort = true;
4081
+ }
4082
+ }
4083
+ }
3741
4084
  const matches = uri2.match(URI_PARSE);
3742
4085
  if (matches) {
3743
4086
  parsed.scheme = matches[1];
@@ -3747,15 +4090,40 @@ var require_fast_uri = __commonJS({
3747
4090
  parsed.path = matches[6] || "";
3748
4091
  parsed.query = matches[7];
3749
4092
  parsed.fragment = matches[8];
4093
+ if (parsed.scheme !== void 0) {
4094
+ const decodedScheme = unescape(parsed.scheme);
4095
+ if (VALID_SCHEME.test(decodedScheme)) {
4096
+ parsed.scheme = decodedScheme.toLowerCase();
4097
+ } else {
4098
+ parsed.error = parsed.error || MALFORMED_SCHEME_ERROR;
4099
+ malformedScheme = true;
4100
+ }
4101
+ }
4102
+ malformedPercentEncoding = hasMalformedComponentPercentEncoding(matches);
4103
+ if (malformedPercentEncoding) {
4104
+ parsed.error = parsed.error || "URI contains malformed percent-encoding.";
4105
+ }
3750
4106
  if (isNaN(parsed.port)) {
3751
4107
  parsed.port = matches[5];
3752
4108
  }
4109
+ const parseError = getParseError(parsed, matches);
4110
+ if (parseError !== void 0) {
4111
+ parsed.error = parsed.error || parseError;
4112
+ malformedAuthorityOrPort = true;
4113
+ }
3753
4114
  if (parsed.host) {
3754
4115
  const ipv4result = isIPv4(parsed.host);
3755
4116
  if (ipv4result === false) {
4117
+ const bracketedIPLiteral = isIPLiteral(parsed.host);
4118
+ const hasIPLiteralBracket = parsed.host.indexOf("[") !== -1 || parsed.host.indexOf("]") !== -1;
3756
4119
  const ipv6result = normalizeIPv6(parsed.host);
3757
- parsed.host = ipv6result.host.toLowerCase();
3758
- isIP = ipv6result.isIPV6;
4120
+ isIP = ipv6result.isIPV6 || ipv6result.isIPVFuture === true;
4121
+ malformedIPLiteral = hasIPLiteralBracket && (!bracketedIPLiteral || ipv6result.error === true);
4122
+ parsed.host = isIP ? ipv6result.host : ipv6result.host.toLowerCase();
4123
+ if (malformedIPLiteral) {
4124
+ parsed.error = parsed.error || "URI host is malformed.";
4125
+ malformedAuthorityOrPort = true;
4126
+ }
3759
4127
  } else {
3760
4128
  isIP = true;
3761
4129
  }
@@ -3773,38 +4141,67 @@ var require_fast_uri = __commonJS({
3773
4141
  parsed.error = parsed.error || "URI is not a " + options.reference + " reference.";
3774
4142
  }
3775
4143
  const schemeHandler = getSchemeHandler(options.scheme || parsed.scheme);
3776
- if (!options.unicodeSupport && (!schemeHandler || !schemeHandler.unicodeSupport)) {
3777
- if (parsed.host && (options.domainHost || schemeHandler && schemeHandler.domainHost) && isIP === false && nonSimpleDomain(parsed.host)) {
3778
- try {
3779
- parsed.host = URL.domainToASCII(parsed.host.toLowerCase());
3780
- } catch (e) {
3781
- parsed.error = parsed.error || "Host's domain name can not be converted to ASCII: " + e;
3782
- }
4144
+ if (!malformedIPLiteral) {
4145
+ malformedHost = canonicalizeHost(parsed, options, schemeHandler, isIP);
4146
+ }
4147
+ if (uri2.indexOf("%") !== -1 && parsed.host !== void 0 && !malformedIPLiteral) {
4148
+ let host = isIP ? parsed.host : normalizePercentEncoding(parsed.host, true);
4149
+ if (!isIP) {
4150
+ host = normalizePercentEncoding(host.toLowerCase());
3783
4151
  }
4152
+ parsed.host = reescapeHostDelimiters(host, isIP);
3784
4153
  }
3785
4154
  if (!schemeHandler || schemeHandler && !schemeHandler.skipNormalize) {
3786
- if (uri2.indexOf("%") !== -1) {
3787
- if (parsed.scheme !== void 0) {
3788
- parsed.scheme = unescape(parsed.scheme);
3789
- }
3790
- if (parsed.host !== void 0) {
3791
- parsed.host = unescape(parsed.host);
3792
- }
3793
- }
3794
4155
  if (parsed.path) {
3795
- parsed.path = escape(unescape(parsed.path));
4156
+ parsed.path = normalizePathEncoding(parsed.path);
4157
+ }
4158
+ if (parsed.query) {
4159
+ parsed.query = normalizeQueryFragmentEncoding(parsed.query);
3796
4160
  }
3797
4161
  if (parsed.fragment) {
3798
- parsed.fragment = encodeURI(decodeURIComponent(parsed.fragment));
4162
+ parsed.fragment = normalizeQueryFragmentEncoding(parsed.fragment);
3799
4163
  }
3800
4164
  }
3801
4165
  if (schemeHandler && schemeHandler.parse) {
3802
4166
  schemeHandler.parse(parsed, options);
4167
+ if (schemeHandler === SCHEMES.urn && parsed.nid === void 0) {
4168
+ malformedSchemeSpecific = true;
4169
+ }
3803
4170
  }
3804
4171
  } else {
3805
4172
  parsed.error = parsed.error || "URI can not be parsed.";
3806
4173
  }
3807
- return parsed;
4174
+ return { parsed, malformedAuthorityOrPort, malformedPercentEncoding, malformedSchemeSpecific, malformedHost, malformedScheme };
4175
+ }
4176
+ function parse3(uri2, opts) {
4177
+ return parseWithStatus(uri2, opts).parsed;
4178
+ }
4179
+ function normalizeString(uri2, opts) {
4180
+ return normalizeStringWithStatus(uri2, opts).normalized;
4181
+ }
4182
+ function normalizeStringWithStatus(uri2, opts) {
4183
+ const { parsed, malformedAuthorityOrPort, malformedPercentEncoding, malformedSchemeSpecific, malformedHost, malformedScheme } = parseWithStatus(uri2, opts);
4184
+ return {
4185
+ normalized: malformedAuthorityOrPort || malformedPercentEncoding || malformedSchemeSpecific || malformedHost || malformedScheme ? uri2 : serialize(parsed, opts),
4186
+ malformedAuthorityOrPort,
4187
+ malformedPercentEncoding,
4188
+ malformedSchemeSpecific,
4189
+ malformedHost,
4190
+ malformedScheme
4191
+ };
4192
+ }
4193
+ function normalizeComparableURI(uri2, opts) {
4194
+ if (typeof uri2 !== "string" && typeof uri2 !== "object") {
4195
+ return void 0;
4196
+ }
4197
+ let value;
4198
+ try {
4199
+ value = typeof uri2 === "string" ? uri2 : serialize(uri2, opts);
4200
+ } catch {
4201
+ return void 0;
4202
+ }
4203
+ const { normalized, malformedAuthorityOrPort, malformedPercentEncoding, malformedSchemeSpecific, malformedHost, malformedScheme } = normalizeStringWithStatus(value, opts);
4204
+ return malformedAuthorityOrPort || malformedPercentEncoding || malformedSchemeSpecific || malformedHost || malformedScheme ? void 0 : normalized;
3808
4205
  }
3809
4206
  var fastUri = {
3810
4207
  SCHEMES,