@pactflow/openapi-pact-comparator 1.6.0 → 1.7.0
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.
- package/dist/cli.cjs +872 -377
- package/dist/cli.cjs.map +1 -1
- package/dist/index.cjs +832 -338
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +832 -338
- package/dist/index.mjs.map +1 -1
- package/dist/src/transform/flattenAllOf.d.ts +2 -0
- package/dist/src/transform/index.d.ts +0 -1
- package/package.json +11 -11
- package/dist/src/transform/requestSchema.d.ts +0 -2
package/dist/cli.cjs
CHANGED
|
@@ -110,7 +110,7 @@ function requireArgument () {
|
|
|
110
110
|
break;
|
|
111
111
|
}
|
|
112
112
|
|
|
113
|
-
if (this._name.
|
|
113
|
+
if (this._name.endsWith('...')) {
|
|
114
114
|
this.variadic = true;
|
|
115
115
|
this._name = this._name.slice(0, -3);
|
|
116
116
|
}
|
|
@@ -130,12 +130,13 @@ function requireArgument () {
|
|
|
130
130
|
* @package
|
|
131
131
|
*/
|
|
132
132
|
|
|
133
|
-
|
|
133
|
+
_collectValue(value, previous) {
|
|
134
134
|
if (previous === this.defaultValue || !Array.isArray(previous)) {
|
|
135
135
|
return [value];
|
|
136
136
|
}
|
|
137
137
|
|
|
138
|
-
|
|
138
|
+
previous.push(value);
|
|
139
|
+
return previous;
|
|
139
140
|
}
|
|
140
141
|
|
|
141
142
|
/**
|
|
@@ -180,7 +181,7 @@ function requireArgument () {
|
|
|
180
181
|
);
|
|
181
182
|
}
|
|
182
183
|
if (this.variadic) {
|
|
183
|
-
return this.
|
|
184
|
+
return this._collectValue(arg, previous);
|
|
184
185
|
}
|
|
185
186
|
return arg;
|
|
186
187
|
};
|
|
@@ -1157,12 +1158,13 @@ function requireOption () {
|
|
|
1157
1158
|
* @package
|
|
1158
1159
|
*/
|
|
1159
1160
|
|
|
1160
|
-
|
|
1161
|
+
_collectValue(value, previous) {
|
|
1161
1162
|
if (previous === this.defaultValue || !Array.isArray(previous)) {
|
|
1162
1163
|
return [value];
|
|
1163
1164
|
}
|
|
1164
1165
|
|
|
1165
|
-
|
|
1166
|
+
previous.push(value);
|
|
1167
|
+
return previous;
|
|
1166
1168
|
}
|
|
1167
1169
|
|
|
1168
1170
|
/**
|
|
@@ -1181,7 +1183,7 @@ function requireOption () {
|
|
|
1181
1183
|
);
|
|
1182
1184
|
}
|
|
1183
1185
|
if (this.variadic) {
|
|
1184
|
-
return this.
|
|
1186
|
+
return this._collectValue(arg, previous);
|
|
1185
1187
|
}
|
|
1186
1188
|
return arg;
|
|
1187
1189
|
};
|
|
@@ -1738,11 +1740,10 @@ function requireCommand () {
|
|
|
1738
1740
|
configureOutput(configuration) {
|
|
1739
1741
|
if (configuration === undefined) return this._outputConfiguration;
|
|
1740
1742
|
|
|
1741
|
-
this._outputConfiguration =
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
);
|
|
1743
|
+
this._outputConfiguration = {
|
|
1744
|
+
...this._outputConfiguration,
|
|
1745
|
+
...configuration,
|
|
1746
|
+
};
|
|
1746
1747
|
return this;
|
|
1747
1748
|
}
|
|
1748
1749
|
|
|
@@ -1868,7 +1869,7 @@ function requireCommand () {
|
|
|
1868
1869
|
*/
|
|
1869
1870
|
addArgument(argument) {
|
|
1870
1871
|
const previousArgument = this.registeredArguments.slice(-1)[0];
|
|
1871
|
-
if (previousArgument
|
|
1872
|
+
if (previousArgument?.variadic) {
|
|
1872
1873
|
throw new Error(
|
|
1873
1874
|
`only the last argument can be variadic '${previousArgument.name()}'`,
|
|
1874
1875
|
);
|
|
@@ -2193,7 +2194,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2193
2194
|
if (val !== null && option.parseArg) {
|
|
2194
2195
|
val = this._callParseArg(option, val, oldValue, invalidValueMessage);
|
|
2195
2196
|
} else if (val !== null && option.variadic) {
|
|
2196
|
-
val = option.
|
|
2197
|
+
val = option._collectValue(val, oldValue);
|
|
2197
2198
|
}
|
|
2198
2199
|
|
|
2199
2200
|
// Fill-in appropriate missing values. Long winded but easy to follow.
|
|
@@ -2972,7 +2973,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2972
2973
|
|
|
2973
2974
|
_chainOrCall(promise, fn) {
|
|
2974
2975
|
// thenable
|
|
2975
|
-
if (promise
|
|
2976
|
+
if (promise?.then && typeof promise.then === 'function') {
|
|
2976
2977
|
// already have a promise, chain callback
|
|
2977
2978
|
return promise.then(() => fn());
|
|
2978
2979
|
}
|
|
@@ -3103,7 +3104,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
3103
3104
|
promiseChain = this._chainOrCallHooks(promiseChain, 'postAction');
|
|
3104
3105
|
return promiseChain;
|
|
3105
3106
|
}
|
|
3106
|
-
if (this.parent
|
|
3107
|
+
if (this.parent?.listenerCount(commandEvent)) {
|
|
3107
3108
|
checkForUnknownOptions();
|
|
3108
3109
|
this._processArguments();
|
|
3109
3110
|
this.parent.emit(commandEvent, operands, unknown); // legacy
|
|
@@ -3233,15 +3234,14 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
3233
3234
|
* sub --unknown uuu op => [sub], [--unknown uuu op]
|
|
3234
3235
|
* sub -- --unknown uuu op => [sub --unknown uuu op], []
|
|
3235
3236
|
*
|
|
3236
|
-
* @param {string[]}
|
|
3237
|
+
* @param {string[]} args
|
|
3237
3238
|
* @return {{operands: string[], unknown: string[]}}
|
|
3238
3239
|
*/
|
|
3239
3240
|
|
|
3240
|
-
parseOptions(
|
|
3241
|
+
parseOptions(args) {
|
|
3241
3242
|
const operands = []; // operands, not options or values
|
|
3242
3243
|
const unknown = []; // first unknown option and remaining unknown args
|
|
3243
3244
|
let dest = operands;
|
|
3244
|
-
const args = argv.slice();
|
|
3245
3245
|
|
|
3246
3246
|
function maybeOption(arg) {
|
|
3247
3247
|
return arg.length > 1 && arg[0] === '-';
|
|
@@ -3260,13 +3260,16 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
3260
3260
|
|
|
3261
3261
|
// parse options
|
|
3262
3262
|
let activeVariadicOption = null;
|
|
3263
|
-
|
|
3264
|
-
|
|
3263
|
+
let activeGroup = null; // working through group of short options, like -abc
|
|
3264
|
+
let i = 0;
|
|
3265
|
+
while (i < args.length || activeGroup) {
|
|
3266
|
+
const arg = activeGroup ?? args[i++];
|
|
3267
|
+
activeGroup = null;
|
|
3265
3268
|
|
|
3266
3269
|
// literal
|
|
3267
3270
|
if (arg === '--') {
|
|
3268
3271
|
if (dest === unknown) dest.push(arg);
|
|
3269
|
-
dest.push(...args);
|
|
3272
|
+
dest.push(...args.slice(i));
|
|
3270
3273
|
break;
|
|
3271
3274
|
}
|
|
3272
3275
|
|
|
@@ -3284,17 +3287,17 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
3284
3287
|
// recognised option, call listener to assign value with possible custom processing
|
|
3285
3288
|
if (option) {
|
|
3286
3289
|
if (option.required) {
|
|
3287
|
-
const value = args
|
|
3290
|
+
const value = args[i++];
|
|
3288
3291
|
if (value === undefined) this.optionMissingArgument(option);
|
|
3289
3292
|
this.emit(`option:${option.name()}`, value);
|
|
3290
3293
|
} else if (option.optional) {
|
|
3291
3294
|
let value = null;
|
|
3292
3295
|
// historical behaviour is optional value is following arg unless an option
|
|
3293
3296
|
if (
|
|
3294
|
-
args.length
|
|
3295
|
-
(!maybeOption(args[
|
|
3297
|
+
i < args.length &&
|
|
3298
|
+
(!maybeOption(args[i]) || negativeNumberArg(args[i]))
|
|
3296
3299
|
) {
|
|
3297
|
-
value = args
|
|
3300
|
+
value = args[i++];
|
|
3298
3301
|
}
|
|
3299
3302
|
this.emit(`option:${option.name()}`, value);
|
|
3300
3303
|
} else {
|
|
@@ -3317,9 +3320,10 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
3317
3320
|
// option with value following in same argument
|
|
3318
3321
|
this.emit(`option:${option.name()}`, arg.slice(2));
|
|
3319
3322
|
} else {
|
|
3320
|
-
// boolean option
|
|
3323
|
+
// boolean option
|
|
3321
3324
|
this.emit(`option:${option.name()}`);
|
|
3322
|
-
|
|
3325
|
+
// remove the processed option and keep processing group
|
|
3326
|
+
activeGroup = `-${arg.slice(2)}`;
|
|
3323
3327
|
}
|
|
3324
3328
|
continue;
|
|
3325
3329
|
}
|
|
@@ -3356,26 +3360,23 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
3356
3360
|
) {
|
|
3357
3361
|
if (this._findCommand(arg)) {
|
|
3358
3362
|
operands.push(arg);
|
|
3359
|
-
|
|
3363
|
+
unknown.push(...args.slice(i));
|
|
3360
3364
|
break;
|
|
3361
3365
|
} else if (
|
|
3362
3366
|
this._getHelpCommand() &&
|
|
3363
3367
|
arg === this._getHelpCommand().name()
|
|
3364
3368
|
) {
|
|
3365
|
-
operands.push(arg);
|
|
3366
|
-
if (args.length > 0) operands.push(...args);
|
|
3369
|
+
operands.push(arg, ...args.slice(i));
|
|
3367
3370
|
break;
|
|
3368
3371
|
} else if (this._defaultCommandName) {
|
|
3369
|
-
unknown.push(arg);
|
|
3370
|
-
if (args.length > 0) unknown.push(...args);
|
|
3372
|
+
unknown.push(arg, ...args.slice(i));
|
|
3371
3373
|
break;
|
|
3372
3374
|
}
|
|
3373
3375
|
}
|
|
3374
3376
|
|
|
3375
3377
|
// If using passThroughOptions, stop processing options at first command-argument.
|
|
3376
3378
|
if (this._passThroughOptions) {
|
|
3377
|
-
dest.push(arg);
|
|
3378
|
-
if (args.length > 0) dest.push(...args);
|
|
3379
|
+
dest.push(arg, ...args.slice(i));
|
|
3379
3380
|
break;
|
|
3380
3381
|
}
|
|
3381
3382
|
|
|
@@ -5152,7 +5153,7 @@ function resolveYamlMerge(data) {
|
|
|
5152
5153
|
return data === '<<' || data === null;
|
|
5153
5154
|
}
|
|
5154
5155
|
|
|
5155
|
-
var merge = new type$b('tag:yaml.org,2002:merge', {
|
|
5156
|
+
var merge$1 = new type$b('tag:yaml.org,2002:merge', {
|
|
5156
5157
|
kind: 'scalar',
|
|
5157
5158
|
resolve: resolveYamlMerge
|
|
5158
5159
|
});
|
|
@@ -5401,7 +5402,7 @@ var set$1 = new type$b('tag:yaml.org,2002:set', {
|
|
|
5401
5402
|
var _default = core$2.extend({
|
|
5402
5403
|
implicit: [
|
|
5403
5404
|
timestamp,
|
|
5404
|
-
merge
|
|
5405
|
+
merge$1
|
|
5405
5406
|
],
|
|
5406
5407
|
explicit: [
|
|
5407
5408
|
binary,
|
|
@@ -8140,7 +8141,7 @@ var types$3 = {
|
|
|
8140
8141
|
timestamp: timestamp,
|
|
8141
8142
|
bool: bool,
|
|
8142
8143
|
int: int,
|
|
8143
|
-
merge: merge,
|
|
8144
|
+
merge: merge$1,
|
|
8144
8145
|
omap: omap,
|
|
8145
8146
|
seq: seq,
|
|
8146
8147
|
str: str
|
|
@@ -9047,6 +9048,18 @@ function overRest(func, start, transform) {
|
|
|
9047
9048
|
};
|
|
9048
9049
|
}
|
|
9049
9050
|
|
|
9051
|
+
/**
|
|
9052
|
+
* The base implementation of `_.rest` which doesn't validate or coerce arguments.
|
|
9053
|
+
*
|
|
9054
|
+
* @private
|
|
9055
|
+
* @param {Function} func The function to apply a rest parameter to.
|
|
9056
|
+
* @param {number} [start=func.length-1] The start position of the rest parameter.
|
|
9057
|
+
* @returns {Function} Returns the new function.
|
|
9058
|
+
*/
|
|
9059
|
+
function baseRest(func, start) {
|
|
9060
|
+
return setToString(overRest(func, start, identity), func + '');
|
|
9061
|
+
}
|
|
9062
|
+
|
|
9050
9063
|
/** Used as references for various `Number` constants. */
|
|
9051
9064
|
var MAX_SAFE_INTEGER = 9007199254740991;
|
|
9052
9065
|
|
|
@@ -9110,6 +9123,63 @@ function isArrayLike(value) {
|
|
|
9110
9123
|
return value != null && isLength(value.length) && !isFunction(value);
|
|
9111
9124
|
}
|
|
9112
9125
|
|
|
9126
|
+
/**
|
|
9127
|
+
* Checks if the given arguments are from an iteratee call.
|
|
9128
|
+
*
|
|
9129
|
+
* @private
|
|
9130
|
+
* @param {*} value The potential iteratee value argument.
|
|
9131
|
+
* @param {*} index The potential iteratee index or key argument.
|
|
9132
|
+
* @param {*} object The potential iteratee object argument.
|
|
9133
|
+
* @returns {boolean} Returns `true` if the arguments are from an iteratee call,
|
|
9134
|
+
* else `false`.
|
|
9135
|
+
*/
|
|
9136
|
+
function isIterateeCall(value, index, object) {
|
|
9137
|
+
if (!isObject(object)) {
|
|
9138
|
+
return false;
|
|
9139
|
+
}
|
|
9140
|
+
var type = typeof index;
|
|
9141
|
+
if (type == 'number'
|
|
9142
|
+
? (isArrayLike(object) && isIndex(index, object.length))
|
|
9143
|
+
: (type == 'string' && index in object)
|
|
9144
|
+
) {
|
|
9145
|
+
return eq(object[index], value);
|
|
9146
|
+
}
|
|
9147
|
+
return false;
|
|
9148
|
+
}
|
|
9149
|
+
|
|
9150
|
+
/**
|
|
9151
|
+
* Creates a function like `_.assign`.
|
|
9152
|
+
*
|
|
9153
|
+
* @private
|
|
9154
|
+
* @param {Function} assigner The function to assign values.
|
|
9155
|
+
* @returns {Function} Returns the new assigner function.
|
|
9156
|
+
*/
|
|
9157
|
+
function createAssigner(assigner) {
|
|
9158
|
+
return baseRest(function(object, sources) {
|
|
9159
|
+
var index = -1,
|
|
9160
|
+
length = sources.length,
|
|
9161
|
+
customizer = length > 1 ? sources[length - 1] : undefined,
|
|
9162
|
+
guard = length > 2 ? sources[2] : undefined;
|
|
9163
|
+
|
|
9164
|
+
customizer = (assigner.length > 3 && typeof customizer == 'function')
|
|
9165
|
+
? (length--, customizer)
|
|
9166
|
+
: undefined;
|
|
9167
|
+
|
|
9168
|
+
if (guard && isIterateeCall(sources[0], sources[1], guard)) {
|
|
9169
|
+
customizer = length < 3 ? undefined : customizer;
|
|
9170
|
+
length = 1;
|
|
9171
|
+
}
|
|
9172
|
+
object = Object(object);
|
|
9173
|
+
while (++index < length) {
|
|
9174
|
+
var source = sources[index];
|
|
9175
|
+
if (source) {
|
|
9176
|
+
assigner(object, source, index, customizer);
|
|
9177
|
+
}
|
|
9178
|
+
}
|
|
9179
|
+
return object;
|
|
9180
|
+
});
|
|
9181
|
+
}
|
|
9182
|
+
|
|
9113
9183
|
/** Used for built-in method references. */
|
|
9114
9184
|
var objectProto$9 = Object.prototype;
|
|
9115
9185
|
|
|
@@ -11341,6 +11411,209 @@ function createBaseEach(eachFunc, fromRight) {
|
|
|
11341
11411
|
*/
|
|
11342
11412
|
var baseEach = createBaseEach(baseForOwn);
|
|
11343
11413
|
|
|
11414
|
+
/**
|
|
11415
|
+
* This function is like `assignValue` except that it doesn't assign
|
|
11416
|
+
* `undefined` values.
|
|
11417
|
+
*
|
|
11418
|
+
* @private
|
|
11419
|
+
* @param {Object} object The object to modify.
|
|
11420
|
+
* @param {string} key The key of the property to assign.
|
|
11421
|
+
* @param {*} value The value to assign.
|
|
11422
|
+
*/
|
|
11423
|
+
function assignMergeValue(object, key, value) {
|
|
11424
|
+
if ((value !== undefined && !eq(object[key], value)) ||
|
|
11425
|
+
(value === undefined && !(key in object))) {
|
|
11426
|
+
baseAssignValue(object, key, value);
|
|
11427
|
+
}
|
|
11428
|
+
}
|
|
11429
|
+
|
|
11430
|
+
/**
|
|
11431
|
+
* This method is like `_.isArrayLike` except that it also checks if `value`
|
|
11432
|
+
* is an object.
|
|
11433
|
+
*
|
|
11434
|
+
* @static
|
|
11435
|
+
* @memberOf _
|
|
11436
|
+
* @since 4.0.0
|
|
11437
|
+
* @category Lang
|
|
11438
|
+
* @param {*} value The value to check.
|
|
11439
|
+
* @returns {boolean} Returns `true` if `value` is an array-like object,
|
|
11440
|
+
* else `false`.
|
|
11441
|
+
* @example
|
|
11442
|
+
*
|
|
11443
|
+
* _.isArrayLikeObject([1, 2, 3]);
|
|
11444
|
+
* // => true
|
|
11445
|
+
*
|
|
11446
|
+
* _.isArrayLikeObject(document.body.children);
|
|
11447
|
+
* // => true
|
|
11448
|
+
*
|
|
11449
|
+
* _.isArrayLikeObject('abc');
|
|
11450
|
+
* // => false
|
|
11451
|
+
*
|
|
11452
|
+
* _.isArrayLikeObject(_.noop);
|
|
11453
|
+
* // => false
|
|
11454
|
+
*/
|
|
11455
|
+
function isArrayLikeObject(value) {
|
|
11456
|
+
return isObjectLike(value) && isArrayLike(value);
|
|
11457
|
+
}
|
|
11458
|
+
|
|
11459
|
+
/**
|
|
11460
|
+
* Gets the value at `key`, unless `key` is "__proto__" or "constructor".
|
|
11461
|
+
*
|
|
11462
|
+
* @private
|
|
11463
|
+
* @param {Object} object The object to query.
|
|
11464
|
+
* @param {string} key The key of the property to get.
|
|
11465
|
+
* @returns {*} Returns the property value.
|
|
11466
|
+
*/
|
|
11467
|
+
function safeGet(object, key) {
|
|
11468
|
+
if (key === 'constructor' && typeof object[key] === 'function') {
|
|
11469
|
+
return;
|
|
11470
|
+
}
|
|
11471
|
+
|
|
11472
|
+
if (key == '__proto__') {
|
|
11473
|
+
return;
|
|
11474
|
+
}
|
|
11475
|
+
|
|
11476
|
+
return object[key];
|
|
11477
|
+
}
|
|
11478
|
+
|
|
11479
|
+
/**
|
|
11480
|
+
* Converts `value` to a plain object flattening inherited enumerable string
|
|
11481
|
+
* keyed properties of `value` to own properties of the plain object.
|
|
11482
|
+
*
|
|
11483
|
+
* @static
|
|
11484
|
+
* @memberOf _
|
|
11485
|
+
* @since 3.0.0
|
|
11486
|
+
* @category Lang
|
|
11487
|
+
* @param {*} value The value to convert.
|
|
11488
|
+
* @returns {Object} Returns the converted plain object.
|
|
11489
|
+
* @example
|
|
11490
|
+
*
|
|
11491
|
+
* function Foo() {
|
|
11492
|
+
* this.b = 2;
|
|
11493
|
+
* }
|
|
11494
|
+
*
|
|
11495
|
+
* Foo.prototype.c = 3;
|
|
11496
|
+
*
|
|
11497
|
+
* _.assign({ 'a': 1 }, new Foo);
|
|
11498
|
+
* // => { 'a': 1, 'b': 2 }
|
|
11499
|
+
*
|
|
11500
|
+
* _.assign({ 'a': 1 }, _.toPlainObject(new Foo));
|
|
11501
|
+
* // => { 'a': 1, 'b': 2, 'c': 3 }
|
|
11502
|
+
*/
|
|
11503
|
+
function toPlainObject(value) {
|
|
11504
|
+
return copyObject(value, keysIn(value));
|
|
11505
|
+
}
|
|
11506
|
+
|
|
11507
|
+
/**
|
|
11508
|
+
* A specialized version of `baseMerge` for arrays and objects which performs
|
|
11509
|
+
* deep merges and tracks traversed objects enabling objects with circular
|
|
11510
|
+
* references to be merged.
|
|
11511
|
+
*
|
|
11512
|
+
* @private
|
|
11513
|
+
* @param {Object} object The destination object.
|
|
11514
|
+
* @param {Object} source The source object.
|
|
11515
|
+
* @param {string} key The key of the value to merge.
|
|
11516
|
+
* @param {number} srcIndex The index of `source`.
|
|
11517
|
+
* @param {Function} mergeFunc The function to merge values.
|
|
11518
|
+
* @param {Function} [customizer] The function to customize assigned values.
|
|
11519
|
+
* @param {Object} [stack] Tracks traversed source values and their merged
|
|
11520
|
+
* counterparts.
|
|
11521
|
+
*/
|
|
11522
|
+
function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) {
|
|
11523
|
+
var objValue = safeGet(object, key),
|
|
11524
|
+
srcValue = safeGet(source, key),
|
|
11525
|
+
stacked = stack.get(srcValue);
|
|
11526
|
+
|
|
11527
|
+
if (stacked) {
|
|
11528
|
+
assignMergeValue(object, key, stacked);
|
|
11529
|
+
return;
|
|
11530
|
+
}
|
|
11531
|
+
var newValue = customizer
|
|
11532
|
+
? customizer(objValue, srcValue, (key + ''), object, source, stack)
|
|
11533
|
+
: undefined;
|
|
11534
|
+
|
|
11535
|
+
var isCommon = newValue === undefined;
|
|
11536
|
+
|
|
11537
|
+
if (isCommon) {
|
|
11538
|
+
var isArr = isArray(srcValue),
|
|
11539
|
+
isBuff = !isArr && isBuffer(srcValue),
|
|
11540
|
+
isTyped = !isArr && !isBuff && isTypedArray(srcValue);
|
|
11541
|
+
|
|
11542
|
+
newValue = srcValue;
|
|
11543
|
+
if (isArr || isBuff || isTyped) {
|
|
11544
|
+
if (isArray(objValue)) {
|
|
11545
|
+
newValue = objValue;
|
|
11546
|
+
}
|
|
11547
|
+
else if (isArrayLikeObject(objValue)) {
|
|
11548
|
+
newValue = copyArray(objValue);
|
|
11549
|
+
}
|
|
11550
|
+
else if (isBuff) {
|
|
11551
|
+
isCommon = false;
|
|
11552
|
+
newValue = cloneBuffer(srcValue, true);
|
|
11553
|
+
}
|
|
11554
|
+
else if (isTyped) {
|
|
11555
|
+
isCommon = false;
|
|
11556
|
+
newValue = cloneTypedArray(srcValue, true);
|
|
11557
|
+
}
|
|
11558
|
+
else {
|
|
11559
|
+
newValue = [];
|
|
11560
|
+
}
|
|
11561
|
+
}
|
|
11562
|
+
else if (isPlainObject(srcValue) || isArguments(srcValue)) {
|
|
11563
|
+
newValue = objValue;
|
|
11564
|
+
if (isArguments(objValue)) {
|
|
11565
|
+
newValue = toPlainObject(objValue);
|
|
11566
|
+
}
|
|
11567
|
+
else if (!isObject(objValue) || isFunction(objValue)) {
|
|
11568
|
+
newValue = initCloneObject(srcValue);
|
|
11569
|
+
}
|
|
11570
|
+
}
|
|
11571
|
+
else {
|
|
11572
|
+
isCommon = false;
|
|
11573
|
+
}
|
|
11574
|
+
}
|
|
11575
|
+
if (isCommon) {
|
|
11576
|
+
// Recursively merge objects and arrays (susceptible to call stack limits).
|
|
11577
|
+
stack.set(srcValue, newValue);
|
|
11578
|
+
mergeFunc(newValue, srcValue, srcIndex, customizer, stack);
|
|
11579
|
+
stack['delete'](srcValue);
|
|
11580
|
+
}
|
|
11581
|
+
assignMergeValue(object, key, newValue);
|
|
11582
|
+
}
|
|
11583
|
+
|
|
11584
|
+
/**
|
|
11585
|
+
* The base implementation of `_.merge` without support for multiple sources.
|
|
11586
|
+
*
|
|
11587
|
+
* @private
|
|
11588
|
+
* @param {Object} object The destination object.
|
|
11589
|
+
* @param {Object} source The source object.
|
|
11590
|
+
* @param {number} srcIndex The index of `source`.
|
|
11591
|
+
* @param {Function} [customizer] The function to customize merged values.
|
|
11592
|
+
* @param {Object} [stack] Tracks traversed source values and their merged
|
|
11593
|
+
* counterparts.
|
|
11594
|
+
*/
|
|
11595
|
+
function baseMerge(object, source, srcIndex, customizer, stack) {
|
|
11596
|
+
if (object === source) {
|
|
11597
|
+
return;
|
|
11598
|
+
}
|
|
11599
|
+
baseFor(source, function(srcValue, key) {
|
|
11600
|
+
stack || (stack = new Stack);
|
|
11601
|
+
if (isObject(srcValue)) {
|
|
11602
|
+
baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);
|
|
11603
|
+
}
|
|
11604
|
+
else {
|
|
11605
|
+
var newValue = customizer
|
|
11606
|
+
? customizer(safeGet(object, key), srcValue, (key + ''), object, source, stack)
|
|
11607
|
+
: undefined;
|
|
11608
|
+
|
|
11609
|
+
if (newValue === undefined) {
|
|
11610
|
+
newValue = srcValue;
|
|
11611
|
+
}
|
|
11612
|
+
assignMergeValue(object, key, newValue);
|
|
11613
|
+
}
|
|
11614
|
+
}, keysIn);
|
|
11615
|
+
}
|
|
11616
|
+
|
|
11344
11617
|
/**
|
|
11345
11618
|
* This function is like `arrayIncludes` except that it accepts a comparator.
|
|
11346
11619
|
*
|
|
@@ -11439,6 +11712,41 @@ function parent(object, path) {
|
|
|
11439
11712
|
return path.length < 2 ? object : baseGet(object, baseSlice(path, 0, -1));
|
|
11440
11713
|
}
|
|
11441
11714
|
|
|
11715
|
+
/**
|
|
11716
|
+
* This method is like `_.assign` except that it recursively merges own and
|
|
11717
|
+
* inherited enumerable string keyed properties of source objects into the
|
|
11718
|
+
* destination object. Source properties that resolve to `undefined` are
|
|
11719
|
+
* skipped if a destination value exists. Array and plain object properties
|
|
11720
|
+
* are merged recursively. Other objects and value types are overridden by
|
|
11721
|
+
* assignment. Source objects are applied from left to right. Subsequent
|
|
11722
|
+
* sources overwrite property assignments of previous sources.
|
|
11723
|
+
*
|
|
11724
|
+
* **Note:** This method mutates `object`.
|
|
11725
|
+
*
|
|
11726
|
+
* @static
|
|
11727
|
+
* @memberOf _
|
|
11728
|
+
* @since 0.5.0
|
|
11729
|
+
* @category Object
|
|
11730
|
+
* @param {Object} object The destination object.
|
|
11731
|
+
* @param {...Object} [sources] The source objects.
|
|
11732
|
+
* @returns {Object} Returns `object`.
|
|
11733
|
+
* @example
|
|
11734
|
+
*
|
|
11735
|
+
* var object = {
|
|
11736
|
+
* 'a': [{ 'b': 2 }, { 'd': 4 }]
|
|
11737
|
+
* };
|
|
11738
|
+
*
|
|
11739
|
+
* var other = {
|
|
11740
|
+
* 'a': [{ 'c': 3 }, { 'e': 5 }]
|
|
11741
|
+
* };
|
|
11742
|
+
*
|
|
11743
|
+
* _.merge(object, other);
|
|
11744
|
+
* // => { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] }
|
|
11745
|
+
*/
|
|
11746
|
+
var merge = createAssigner(function(object, source, srcIndex) {
|
|
11747
|
+
baseMerge(object, source, srcIndex);
|
|
11748
|
+
});
|
|
11749
|
+
|
|
11442
11750
|
/**
|
|
11443
11751
|
* The base implementation of `_.unset`.
|
|
11444
11752
|
*
|
|
@@ -11755,22 +12063,6 @@ const traverseWithDereferencing = (schema, visitor) => {
|
|
|
11755
12063
|
_traverseWithDereferencing(schema, schema, [], visitor);
|
|
11756
12064
|
};
|
|
11757
12065
|
|
|
11758
|
-
const transformRequestSchema = (schema) => {
|
|
11759
|
-
// OpenAPI defines allOf to mean the union of all sub-schemas. JSON-Schema
|
|
11760
|
-
// defines allOf to mean that *every* sub-schema needs to be satisfied. In
|
|
11761
|
-
// draft 2019-09, JSON-Schema added "unevaluatedProperties" to support this
|
|
11762
|
-
// behaviour
|
|
11763
|
-
traverseWithDereferencing(schema, (s) => {
|
|
11764
|
-
if (s.allOf) {
|
|
11765
|
-
forEach(s.allOf, (ss) => {
|
|
11766
|
-
delete ss.additionalProperties;
|
|
11767
|
-
});
|
|
11768
|
-
s.unevaluatedProperties = false;
|
|
11769
|
-
}
|
|
11770
|
-
});
|
|
11771
|
-
return schema;
|
|
11772
|
-
};
|
|
11773
|
-
|
|
11774
12066
|
const transformResponseSchema = (schema, noTransformNonNullableResponseSchema) => {
|
|
11775
12067
|
// a provider must provide a superset of what the consumer asks for
|
|
11776
12068
|
// additionalProperties expected in pact response are disallowed
|
|
@@ -11794,30 +12086,62 @@ const transformResponseSchema = (schema, noTransformNonNullableResponseSchema) =
|
|
|
11794
12086
|
}
|
|
11795
12087
|
delete s.required;
|
|
11796
12088
|
});
|
|
11797
|
-
// OpenAPI defines allOf to mean the union of all sub-schemas. JSON-Schema
|
|
11798
|
-
// defines allOf to mean that *every* sub-schema needs to be satisfied. In
|
|
11799
|
-
// draft 2019-09, JSON-Schema added "unevaluatedProperties" to support this
|
|
11800
|
-
// behaviour
|
|
11801
|
-
traverseWithDereferencing(schema, (s) => {
|
|
11802
|
-
if (s.allOf) {
|
|
11803
|
-
forEach(s.allOf, (ss) => {
|
|
11804
|
-
let subschema = ss;
|
|
11805
|
-
if (subschema.$ref) {
|
|
11806
|
-
subschema = get$1(schema, splitPath(subschema.$ref));
|
|
11807
|
-
}
|
|
11808
|
-
delete subschema.additionalProperties;
|
|
11809
|
-
if (subschema.allOf) {
|
|
11810
|
-
// traversal is depth-first; if nested allOf, remove
|
|
11811
|
-
// unevaluatedProperties from previously set deeper schema
|
|
11812
|
-
delete subschema.unevaluatedProperties;
|
|
11813
|
-
}
|
|
11814
|
-
});
|
|
11815
|
-
s.unevaluatedProperties = false;
|
|
11816
|
-
}
|
|
11817
|
-
});
|
|
11818
12089
|
return schema;
|
|
11819
12090
|
};
|
|
11820
12091
|
|
|
12092
|
+
function _flat(s, root) {
|
|
12093
|
+
if (s.allOf) {
|
|
12094
|
+
const { allOf, ...others } = s;
|
|
12095
|
+
return merge(others, ...allOf.map((ss) => {
|
|
12096
|
+
let dereferenced;
|
|
12097
|
+
if (ss.$ref) {
|
|
12098
|
+
const { $ref, ...others } = ss;
|
|
12099
|
+
dereferenced = {
|
|
12100
|
+
...others,
|
|
12101
|
+
...get$1(root, splitPath($ref)),
|
|
12102
|
+
};
|
|
12103
|
+
}
|
|
12104
|
+
return _flat(dereferenced || ss, root);
|
|
12105
|
+
}));
|
|
12106
|
+
}
|
|
12107
|
+
if (s.properties) {
|
|
12108
|
+
for (const ss in s.properties) {
|
|
12109
|
+
s.properties[ss] = _flat(s.properties[ss], root);
|
|
12110
|
+
}
|
|
12111
|
+
return s;
|
|
12112
|
+
}
|
|
12113
|
+
for (const key of [
|
|
12114
|
+
"oneOf",
|
|
12115
|
+
"anyOf",
|
|
12116
|
+
"not",
|
|
12117
|
+
"items",
|
|
12118
|
+
"additionalProperties",
|
|
12119
|
+
]) {
|
|
12120
|
+
if (s[key]) {
|
|
12121
|
+
return {
|
|
12122
|
+
...s,
|
|
12123
|
+
[key]: Array.isArray(s[key])
|
|
12124
|
+
? s[key].map((ss) => _flat(ss, root))
|
|
12125
|
+
: _flat(s[key], root),
|
|
12126
|
+
};
|
|
12127
|
+
}
|
|
12128
|
+
}
|
|
12129
|
+
return s;
|
|
12130
|
+
}
|
|
12131
|
+
// OpenAPI defines allOf to mean the union of all sub-schemas. JSON-Schema
|
|
12132
|
+
// defines allOf to mean that *every* sub-schema needs to be satisfied.
|
|
12133
|
+
// To handle the difference, we flatten 'allOf'
|
|
12134
|
+
function flattenAllOf(s, refs) {
|
|
12135
|
+
// main schema
|
|
12136
|
+
const flattened = _flat(s, s);
|
|
12137
|
+
// any other references
|
|
12138
|
+
for (const ref of refs) {
|
|
12139
|
+
const path = splitPath(ref);
|
|
12140
|
+
set(flattened, path, _flat(get$1(s, path), s));
|
|
12141
|
+
}
|
|
12142
|
+
return flattened;
|
|
12143
|
+
}
|
|
12144
|
+
|
|
11821
12145
|
// draft-06 onwards converts exclusiveMinimum and exclusiveMaximum to numbers
|
|
11822
12146
|
const convertExclusiveMinMax = (s) => {
|
|
11823
12147
|
if (s.exclusiveMaximum === true) {
|
|
@@ -11880,12 +12204,13 @@ const minimumSchema = (originalSchema, oas) => {
|
|
|
11880
12204
|
const subschema = cloneDeep(get$1(oas, path, {}));
|
|
11881
12205
|
delete subschema.description;
|
|
11882
12206
|
delete subschema.example;
|
|
12207
|
+
traverse(subschema, cleanupDiscriminators);
|
|
11883
12208
|
traverse(subschema, collectReferences);
|
|
11884
12209
|
traverse(subschema, handleNullableSchema);
|
|
11885
12210
|
traverse(subschema, convertExclusiveMinMax);
|
|
11886
12211
|
set(schema, path, subschema);
|
|
11887
12212
|
}
|
|
11888
|
-
return schema;
|
|
12213
|
+
return flattenAllOf(schema, refAdded);
|
|
11889
12214
|
};
|
|
11890
12215
|
|
|
11891
12216
|
const isSimpleSchema = (s, oas) => {
|
|
@@ -15493,7 +15818,7 @@ function* compareReqBody(ajv, route, interaction, index, config) {
|
|
|
15493
15818
|
: true)) {
|
|
15494
15819
|
const value = parseBody(body, requestContentType, config.get("legacy-parser"));
|
|
15495
15820
|
const schemaId = `[root].paths.${path}.${method}.requestBody.content.${contentType}`;
|
|
15496
|
-
const validate = getValidateFunction(ajv, schemaId, () =>
|
|
15821
|
+
const validate = getValidateFunction(ajv, schemaId, () => minimumSchema(schema, oas));
|
|
15497
15822
|
if (!validate(value)) {
|
|
15498
15823
|
for (const error of validate.errors) {
|
|
15499
15824
|
yield {
|
|
@@ -23326,44 +23651,6 @@ var uri = {};
|
|
|
23326
23651
|
|
|
23327
23652
|
var fastUri = {exports: {}};
|
|
23328
23653
|
|
|
23329
|
-
var scopedChars;
|
|
23330
|
-
var hasRequiredScopedChars;
|
|
23331
|
-
|
|
23332
|
-
function requireScopedChars () {
|
|
23333
|
-
if (hasRequiredScopedChars) return scopedChars;
|
|
23334
|
-
hasRequiredScopedChars = 1;
|
|
23335
|
-
|
|
23336
|
-
const HEX = {
|
|
23337
|
-
0: 0,
|
|
23338
|
-
1: 1,
|
|
23339
|
-
2: 2,
|
|
23340
|
-
3: 3,
|
|
23341
|
-
4: 4,
|
|
23342
|
-
5: 5,
|
|
23343
|
-
6: 6,
|
|
23344
|
-
7: 7,
|
|
23345
|
-
8: 8,
|
|
23346
|
-
9: 9,
|
|
23347
|
-
a: 10,
|
|
23348
|
-
A: 10,
|
|
23349
|
-
b: 11,
|
|
23350
|
-
B: 11,
|
|
23351
|
-
c: 12,
|
|
23352
|
-
C: 12,
|
|
23353
|
-
d: 13,
|
|
23354
|
-
D: 13,
|
|
23355
|
-
e: 14,
|
|
23356
|
-
E: 14,
|
|
23357
|
-
f: 15,
|
|
23358
|
-
F: 15
|
|
23359
|
-
};
|
|
23360
|
-
|
|
23361
|
-
scopedChars = {
|
|
23362
|
-
HEX
|
|
23363
|
-
};
|
|
23364
|
-
return scopedChars;
|
|
23365
|
-
}
|
|
23366
|
-
|
|
23367
23654
|
var utils;
|
|
23368
23655
|
var hasRequiredUtils;
|
|
23369
23656
|
|
|
@@ -23371,62 +23658,100 @@ function requireUtils () {
|
|
|
23371
23658
|
if (hasRequiredUtils) return utils;
|
|
23372
23659
|
hasRequiredUtils = 1;
|
|
23373
23660
|
|
|
23374
|
-
|
|
23661
|
+
/** @type {(value: string) => boolean} */
|
|
23662
|
+
const isUUID = RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu);
|
|
23375
23663
|
|
|
23376
|
-
|
|
23664
|
+
/** @type {(value: string) => boolean} */
|
|
23665
|
+
const 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);
|
|
23377
23666
|
|
|
23378
|
-
|
|
23379
|
-
|
|
23380
|
-
|
|
23381
|
-
|
|
23382
|
-
|
|
23383
|
-
|
|
23384
|
-
|
|
23385
|
-
|
|
23667
|
+
/**
|
|
23668
|
+
* @param {Array<string>} input
|
|
23669
|
+
* @returns {string}
|
|
23670
|
+
*/
|
|
23671
|
+
function stringArrayToHexStripped (input) {
|
|
23672
|
+
let acc = '';
|
|
23673
|
+
let code = 0;
|
|
23674
|
+
let i = 0;
|
|
23675
|
+
|
|
23676
|
+
for (i = 0; i < input.length; i++) {
|
|
23677
|
+
code = input[i].charCodeAt(0);
|
|
23678
|
+
if (code === 48) {
|
|
23679
|
+
continue
|
|
23680
|
+
}
|
|
23681
|
+
if (!((code >= 48 && code <= 57) || (code >= 65 && code <= 70) || (code >= 97 && code <= 102))) {
|
|
23682
|
+
return ''
|
|
23683
|
+
}
|
|
23684
|
+
acc += input[i];
|
|
23685
|
+
break
|
|
23686
|
+
}
|
|
23687
|
+
|
|
23688
|
+
for (i += 1; i < input.length; i++) {
|
|
23689
|
+
code = input[i].charCodeAt(0);
|
|
23690
|
+
if (!((code >= 48 && code <= 57) || (code >= 65 && code <= 70) || (code >= 97 && code <= 102))) {
|
|
23691
|
+
return ''
|
|
23692
|
+
}
|
|
23693
|
+
acc += input[i];
|
|
23386
23694
|
}
|
|
23695
|
+
return acc
|
|
23387
23696
|
}
|
|
23388
23697
|
|
|
23389
23698
|
/**
|
|
23390
|
-
* @
|
|
23391
|
-
* @
|
|
23392
|
-
* @
|
|
23699
|
+
* @typedef {Object} GetIPV6Result
|
|
23700
|
+
* @property {boolean} error - Indicates if there was an error parsing the IPv6 address.
|
|
23701
|
+
* @property {string} address - The parsed IPv6 address.
|
|
23702
|
+
* @property {string} [zone] - The zone identifier, if present.
|
|
23393
23703
|
*/
|
|
23394
|
-
|
|
23395
|
-
|
|
23396
|
-
|
|
23397
|
-
|
|
23398
|
-
|
|
23399
|
-
|
|
23400
|
-
|
|
23704
|
+
|
|
23705
|
+
/**
|
|
23706
|
+
* @param {string} value
|
|
23707
|
+
* @returns {boolean}
|
|
23708
|
+
*/
|
|
23709
|
+
const nonSimpleDomain = RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);
|
|
23710
|
+
|
|
23711
|
+
/**
|
|
23712
|
+
* @param {Array<string>} buffer
|
|
23713
|
+
* @returns {boolean}
|
|
23714
|
+
*/
|
|
23715
|
+
function consumeIsZone (buffer) {
|
|
23716
|
+
buffer.length = 0;
|
|
23717
|
+
return true
|
|
23718
|
+
}
|
|
23719
|
+
|
|
23720
|
+
/**
|
|
23721
|
+
* @param {Array<string>} buffer
|
|
23722
|
+
* @param {Array<string>} address
|
|
23723
|
+
* @param {GetIPV6Result} output
|
|
23724
|
+
* @returns {boolean}
|
|
23725
|
+
*/
|
|
23726
|
+
function consumeHextets (buffer, address, output) {
|
|
23727
|
+
if (buffer.length) {
|
|
23728
|
+
const hex = stringArrayToHexStripped(buffer);
|
|
23729
|
+
if (hex !== '') {
|
|
23730
|
+
address.push(hex);
|
|
23731
|
+
} else {
|
|
23732
|
+
output.error = true;
|
|
23733
|
+
return false
|
|
23734
|
+
}
|
|
23735
|
+
buffer.length = 0;
|
|
23401
23736
|
}
|
|
23402
|
-
|
|
23403
|
-
return acc
|
|
23737
|
+
return true
|
|
23404
23738
|
}
|
|
23405
23739
|
|
|
23740
|
+
/**
|
|
23741
|
+
* @param {string} input
|
|
23742
|
+
* @returns {GetIPV6Result}
|
|
23743
|
+
*/
|
|
23406
23744
|
function getIPV6 (input) {
|
|
23407
23745
|
let tokenCount = 0;
|
|
23408
23746
|
const output = { error: false, address: '', zone: '' };
|
|
23747
|
+
/** @type {Array<string>} */
|
|
23409
23748
|
const address = [];
|
|
23749
|
+
/** @type {Array<string>} */
|
|
23410
23750
|
const buffer = [];
|
|
23411
|
-
let isZone = false;
|
|
23412
23751
|
let endipv6Encountered = false;
|
|
23413
23752
|
let endIpv6 = false;
|
|
23414
23753
|
|
|
23415
|
-
|
|
23416
|
-
if (buffer.length) {
|
|
23417
|
-
if (isZone === false) {
|
|
23418
|
-
const hex = stringArrayToHexStripped(buffer);
|
|
23419
|
-
if (hex !== undefined) {
|
|
23420
|
-
address.push(hex);
|
|
23421
|
-
} else {
|
|
23422
|
-
output.error = true;
|
|
23423
|
-
return false
|
|
23424
|
-
}
|
|
23425
|
-
}
|
|
23426
|
-
buffer.length = 0;
|
|
23427
|
-
}
|
|
23428
|
-
return true
|
|
23429
|
-
}
|
|
23754
|
+
let consume = consumeHextets;
|
|
23430
23755
|
|
|
23431
23756
|
for (let i = 0; i < input.length; i++) {
|
|
23432
23757
|
const cursor = input[i];
|
|
@@ -23435,29 +23760,28 @@ function requireUtils () {
|
|
|
23435
23760
|
if (endipv6Encountered === true) {
|
|
23436
23761
|
endIpv6 = true;
|
|
23437
23762
|
}
|
|
23438
|
-
if (!consume()) { break }
|
|
23439
|
-
tokenCount
|
|
23440
|
-
address.push(':');
|
|
23441
|
-
if (tokenCount > 7) {
|
|
23763
|
+
if (!consume(buffer, address, output)) { break }
|
|
23764
|
+
if (++tokenCount > 7) {
|
|
23442
23765
|
// not valid
|
|
23443
23766
|
output.error = true;
|
|
23444
23767
|
break
|
|
23445
23768
|
}
|
|
23446
|
-
if (i
|
|
23769
|
+
if (i > 0 && input[i - 1] === ':') {
|
|
23447
23770
|
endipv6Encountered = true;
|
|
23448
23771
|
}
|
|
23772
|
+
address.push(':');
|
|
23449
23773
|
continue
|
|
23450
23774
|
} else if (cursor === '%') {
|
|
23451
|
-
if (!consume()) { break }
|
|
23775
|
+
if (!consume(buffer, address, output)) { break }
|
|
23452
23776
|
// switch to zone detection
|
|
23453
|
-
|
|
23777
|
+
consume = consumeIsZone;
|
|
23454
23778
|
} else {
|
|
23455
23779
|
buffer.push(cursor);
|
|
23456
23780
|
continue
|
|
23457
23781
|
}
|
|
23458
23782
|
}
|
|
23459
23783
|
if (buffer.length) {
|
|
23460
|
-
if (
|
|
23784
|
+
if (consume === consumeIsZone) {
|
|
23461
23785
|
output.zone = buffer.join('');
|
|
23462
23786
|
} else if (endIpv6) {
|
|
23463
23787
|
address.push(buffer.join(''));
|
|
@@ -23469,6 +23793,17 @@ function requireUtils () {
|
|
|
23469
23793
|
return output
|
|
23470
23794
|
}
|
|
23471
23795
|
|
|
23796
|
+
/**
|
|
23797
|
+
* @typedef {Object} NormalizeIPv6Result
|
|
23798
|
+
* @property {string} host - The normalized host.
|
|
23799
|
+
* @property {string} [escapedHost] - The escaped host.
|
|
23800
|
+
* @property {boolean} isIPV6 - Indicates if the host is an IPv6 address.
|
|
23801
|
+
*/
|
|
23802
|
+
|
|
23803
|
+
/**
|
|
23804
|
+
* @param {string} host
|
|
23805
|
+
* @returns {NormalizeIPv6Result}
|
|
23806
|
+
*/
|
|
23472
23807
|
function normalizeIPv6 (host) {
|
|
23473
23808
|
if (findToken(host, ':') < 2) { return { host, isIPV6: false } }
|
|
23474
23809
|
const ipv6 = getIPV6(host);
|
|
@@ -23480,35 +23815,17 @@ function requireUtils () {
|
|
|
23480
23815
|
newHost += '%' + ipv6.zone;
|
|
23481
23816
|
escapedHost += '%25' + ipv6.zone;
|
|
23482
23817
|
}
|
|
23483
|
-
return { host: newHost,
|
|
23818
|
+
return { host: newHost, isIPV6: true, escapedHost }
|
|
23484
23819
|
} else {
|
|
23485
23820
|
return { host, isIPV6: false }
|
|
23486
23821
|
}
|
|
23487
23822
|
}
|
|
23488
23823
|
|
|
23489
|
-
|
|
23490
|
-
|
|
23491
|
-
|
|
23492
|
-
|
|
23493
|
-
|
|
23494
|
-
const c = str[i];
|
|
23495
|
-
if (c === '0' && skip) {
|
|
23496
|
-
if ((i + 1 <= l && str[i + 1] === token) || i + 1 === l) {
|
|
23497
|
-
out += c;
|
|
23498
|
-
skip = false;
|
|
23499
|
-
}
|
|
23500
|
-
} else {
|
|
23501
|
-
if (c === token) {
|
|
23502
|
-
skip = true;
|
|
23503
|
-
} else {
|
|
23504
|
-
skip = false;
|
|
23505
|
-
}
|
|
23506
|
-
out += c;
|
|
23507
|
-
}
|
|
23508
|
-
}
|
|
23509
|
-
return out
|
|
23510
|
-
}
|
|
23511
|
-
|
|
23824
|
+
/**
|
|
23825
|
+
* @param {string} str
|
|
23826
|
+
* @param {string} token
|
|
23827
|
+
* @returns {number}
|
|
23828
|
+
*/
|
|
23512
23829
|
function findToken (str, token) {
|
|
23513
23830
|
let ind = 0;
|
|
23514
23831
|
for (let i = 0; i < str.length; i++) {
|
|
@@ -23517,98 +23834,160 @@ function requireUtils () {
|
|
|
23517
23834
|
return ind
|
|
23518
23835
|
}
|
|
23519
23836
|
|
|
23520
|
-
|
|
23521
|
-
|
|
23522
|
-
|
|
23523
|
-
|
|
23524
|
-
|
|
23525
|
-
|
|
23837
|
+
/**
|
|
23838
|
+
* @param {string} path
|
|
23839
|
+
* @returns {string}
|
|
23840
|
+
*
|
|
23841
|
+
* @see https://datatracker.ietf.org/doc/html/rfc3986#section-5.2.4
|
|
23842
|
+
*/
|
|
23843
|
+
function removeDotSegments (path) {
|
|
23844
|
+
let input = path;
|
|
23526
23845
|
const output = [];
|
|
23846
|
+
let nextSlash = -1;
|
|
23847
|
+
let len = 0;
|
|
23527
23848
|
|
|
23528
|
-
|
|
23529
|
-
|
|
23530
|
-
|
|
23531
|
-
|
|
23532
|
-
|
|
23533
|
-
|
|
23534
|
-
|
|
23535
|
-
|
|
23536
|
-
} else if (input === '.' || input === '..') {
|
|
23537
|
-
input = '';
|
|
23538
|
-
} else {
|
|
23539
|
-
const im = input.match(RDS5);
|
|
23540
|
-
if (im) {
|
|
23541
|
-
const s = im[0];
|
|
23542
|
-
input = input.slice(s.length);
|
|
23543
|
-
output.push(s);
|
|
23849
|
+
// eslint-disable-next-line no-cond-assign
|
|
23850
|
+
while (len = input.length) {
|
|
23851
|
+
if (len === 1) {
|
|
23852
|
+
if (input === '.') {
|
|
23853
|
+
break
|
|
23854
|
+
} else if (input === '/') {
|
|
23855
|
+
output.push('/');
|
|
23856
|
+
break
|
|
23544
23857
|
} else {
|
|
23545
|
-
|
|
23858
|
+
output.push(input);
|
|
23859
|
+
break
|
|
23860
|
+
}
|
|
23861
|
+
} else if (len === 2) {
|
|
23862
|
+
if (input[0] === '.') {
|
|
23863
|
+
if (input[1] === '.') {
|
|
23864
|
+
break
|
|
23865
|
+
} else if (input[1] === '/') {
|
|
23866
|
+
input = input.slice(2);
|
|
23867
|
+
continue
|
|
23868
|
+
}
|
|
23869
|
+
} else if (input[0] === '/') {
|
|
23870
|
+
if (input[1] === '.' || input[1] === '/') {
|
|
23871
|
+
output.push('/');
|
|
23872
|
+
break
|
|
23873
|
+
}
|
|
23874
|
+
}
|
|
23875
|
+
} else if (len === 3) {
|
|
23876
|
+
if (input === '/..') {
|
|
23877
|
+
if (output.length !== 0) {
|
|
23878
|
+
output.pop();
|
|
23879
|
+
}
|
|
23880
|
+
output.push('/');
|
|
23881
|
+
break
|
|
23546
23882
|
}
|
|
23547
23883
|
}
|
|
23884
|
+
if (input[0] === '.') {
|
|
23885
|
+
if (input[1] === '.') {
|
|
23886
|
+
if (input[2] === '/') {
|
|
23887
|
+
input = input.slice(3);
|
|
23888
|
+
continue
|
|
23889
|
+
}
|
|
23890
|
+
} else if (input[1] === '/') {
|
|
23891
|
+
input = input.slice(2);
|
|
23892
|
+
continue
|
|
23893
|
+
}
|
|
23894
|
+
} else if (input[0] === '/') {
|
|
23895
|
+
if (input[1] === '.') {
|
|
23896
|
+
if (input[2] === '/') {
|
|
23897
|
+
input = input.slice(2);
|
|
23898
|
+
continue
|
|
23899
|
+
} else if (input[2] === '.') {
|
|
23900
|
+
if (input[3] === '/') {
|
|
23901
|
+
input = input.slice(3);
|
|
23902
|
+
if (output.length !== 0) {
|
|
23903
|
+
output.pop();
|
|
23904
|
+
}
|
|
23905
|
+
continue
|
|
23906
|
+
}
|
|
23907
|
+
}
|
|
23908
|
+
}
|
|
23909
|
+
}
|
|
23910
|
+
|
|
23911
|
+
// Rule 2E: Move normal path segment to output
|
|
23912
|
+
if ((nextSlash = input.indexOf('/', 1)) === -1) {
|
|
23913
|
+
output.push(input);
|
|
23914
|
+
break
|
|
23915
|
+
} else {
|
|
23916
|
+
output.push(input.slice(0, nextSlash));
|
|
23917
|
+
input = input.slice(nextSlash);
|
|
23918
|
+
}
|
|
23548
23919
|
}
|
|
23920
|
+
|
|
23549
23921
|
return output.join('')
|
|
23550
23922
|
}
|
|
23551
23923
|
|
|
23552
|
-
|
|
23924
|
+
/**
|
|
23925
|
+
* @param {import('../types/index').URIComponent} component
|
|
23926
|
+
* @param {boolean} esc
|
|
23927
|
+
* @returns {import('../types/index').URIComponent}
|
|
23928
|
+
*/
|
|
23929
|
+
function normalizeComponentEncoding (component, esc) {
|
|
23553
23930
|
const func = esc !== true ? escape : unescape;
|
|
23554
|
-
if (
|
|
23555
|
-
|
|
23931
|
+
if (component.scheme !== undefined) {
|
|
23932
|
+
component.scheme = func(component.scheme);
|
|
23556
23933
|
}
|
|
23557
|
-
if (
|
|
23558
|
-
|
|
23934
|
+
if (component.userinfo !== undefined) {
|
|
23935
|
+
component.userinfo = func(component.userinfo);
|
|
23559
23936
|
}
|
|
23560
|
-
if (
|
|
23561
|
-
|
|
23937
|
+
if (component.host !== undefined) {
|
|
23938
|
+
component.host = func(component.host);
|
|
23562
23939
|
}
|
|
23563
|
-
if (
|
|
23564
|
-
|
|
23940
|
+
if (component.path !== undefined) {
|
|
23941
|
+
component.path = func(component.path);
|
|
23565
23942
|
}
|
|
23566
|
-
if (
|
|
23567
|
-
|
|
23943
|
+
if (component.query !== undefined) {
|
|
23944
|
+
component.query = func(component.query);
|
|
23568
23945
|
}
|
|
23569
|
-
if (
|
|
23570
|
-
|
|
23946
|
+
if (component.fragment !== undefined) {
|
|
23947
|
+
component.fragment = func(component.fragment);
|
|
23571
23948
|
}
|
|
23572
|
-
return
|
|
23949
|
+
return component
|
|
23573
23950
|
}
|
|
23574
23951
|
|
|
23575
|
-
|
|
23952
|
+
/**
|
|
23953
|
+
* @param {import('../types/index').URIComponent} component
|
|
23954
|
+
* @returns {string|undefined}
|
|
23955
|
+
*/
|
|
23956
|
+
function recomposeAuthority (component) {
|
|
23576
23957
|
const uriTokens = [];
|
|
23577
23958
|
|
|
23578
|
-
if (
|
|
23579
|
-
uriTokens.push(
|
|
23959
|
+
if (component.userinfo !== undefined) {
|
|
23960
|
+
uriTokens.push(component.userinfo);
|
|
23580
23961
|
uriTokens.push('@');
|
|
23581
23962
|
}
|
|
23582
23963
|
|
|
23583
|
-
if (
|
|
23584
|
-
let host = unescape(
|
|
23585
|
-
|
|
23586
|
-
|
|
23587
|
-
if (ipV4res.isIPV4) {
|
|
23588
|
-
host = ipV4res.host;
|
|
23589
|
-
} else {
|
|
23590
|
-
const ipV6res = normalizeIPv6(ipV4res.host);
|
|
23964
|
+
if (component.host !== undefined) {
|
|
23965
|
+
let host = unescape(component.host);
|
|
23966
|
+
if (!isIPv4(host)) {
|
|
23967
|
+
const ipV6res = normalizeIPv6(host);
|
|
23591
23968
|
if (ipV6res.isIPV6 === true) {
|
|
23592
23969
|
host = `[${ipV6res.escapedHost}]`;
|
|
23593
23970
|
} else {
|
|
23594
|
-
host =
|
|
23971
|
+
host = component.host;
|
|
23595
23972
|
}
|
|
23596
23973
|
}
|
|
23597
23974
|
uriTokens.push(host);
|
|
23598
23975
|
}
|
|
23599
23976
|
|
|
23600
|
-
if (typeof
|
|
23977
|
+
if (typeof component.port === 'number' || typeof component.port === 'string') {
|
|
23601
23978
|
uriTokens.push(':');
|
|
23602
|
-
uriTokens.push(String(
|
|
23979
|
+
uriTokens.push(String(component.port));
|
|
23603
23980
|
}
|
|
23604
23981
|
|
|
23605
23982
|
return uriTokens.length ? uriTokens.join('') : undefined
|
|
23606
23983
|
}
|
|
23607
23984
|
utils = {
|
|
23985
|
+
nonSimpleDomain,
|
|
23608
23986
|
recomposeAuthority,
|
|
23609
23987
|
normalizeComponentEncoding,
|
|
23610
23988
|
removeDotSegments,
|
|
23611
|
-
|
|
23989
|
+
isIPv4,
|
|
23990
|
+
isUUID,
|
|
23612
23991
|
normalizeIPv6,
|
|
23613
23992
|
stringArrayToHexStripped
|
|
23614
23993
|
};
|
|
@@ -23622,192 +24001,271 @@ function requireSchemes () {
|
|
|
23622
24001
|
if (hasRequiredSchemes) return schemes;
|
|
23623
24002
|
hasRequiredSchemes = 1;
|
|
23624
24003
|
|
|
23625
|
-
const
|
|
24004
|
+
const { isUUID } = requireUtils();
|
|
23626
24005
|
const URN_REG = /([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu;
|
|
23627
24006
|
|
|
23628
|
-
|
|
23629
|
-
|
|
24007
|
+
const supportedSchemeNames = /** @type {const} */ (['http', 'https', 'ws',
|
|
24008
|
+
'wss', 'urn', 'urn:uuid']);
|
|
24009
|
+
|
|
24010
|
+
/** @typedef {supportedSchemeNames[number]} SchemeName */
|
|
24011
|
+
|
|
24012
|
+
/**
|
|
24013
|
+
* @param {string} name
|
|
24014
|
+
* @returns {name is SchemeName}
|
|
24015
|
+
*/
|
|
24016
|
+
function isValidSchemeName (name) {
|
|
24017
|
+
return supportedSchemeNames.indexOf(/** @type {*} */ (name)) !== -1
|
|
23630
24018
|
}
|
|
23631
24019
|
|
|
23632
|
-
|
|
23633
|
-
|
|
23634
|
-
|
|
24020
|
+
/**
|
|
24021
|
+
* @callback SchemeFn
|
|
24022
|
+
* @param {import('../types/index').URIComponent} component
|
|
24023
|
+
* @param {import('../types/index').Options} options
|
|
24024
|
+
* @returns {import('../types/index').URIComponent}
|
|
24025
|
+
*/
|
|
24026
|
+
|
|
24027
|
+
/**
|
|
24028
|
+
* @typedef {Object} SchemeHandler
|
|
24029
|
+
* @property {SchemeName} scheme - The scheme name.
|
|
24030
|
+
* @property {boolean} [domainHost] - Indicates if the scheme supports domain hosts.
|
|
24031
|
+
* @property {SchemeFn} parse - Function to parse the URI component for this scheme.
|
|
24032
|
+
* @property {SchemeFn} serialize - Function to serialize the URI component for this scheme.
|
|
24033
|
+
* @property {boolean} [skipNormalize] - Indicates if normalization should be skipped for this scheme.
|
|
24034
|
+
* @property {boolean} [absolutePath] - Indicates if the scheme uses absolute paths.
|
|
24035
|
+
* @property {boolean} [unicodeSupport] - Indicates if the scheme supports Unicode.
|
|
24036
|
+
*/
|
|
24037
|
+
|
|
24038
|
+
/**
|
|
24039
|
+
* @param {import('../types/index').URIComponent} wsComponent
|
|
24040
|
+
* @returns {boolean}
|
|
24041
|
+
*/
|
|
24042
|
+
function wsIsSecure (wsComponent) {
|
|
24043
|
+
if (wsComponent.secure === true) {
|
|
24044
|
+
return true
|
|
24045
|
+
} else if (wsComponent.secure === false) {
|
|
24046
|
+
return false
|
|
24047
|
+
} else if (wsComponent.scheme) {
|
|
24048
|
+
return (
|
|
24049
|
+
wsComponent.scheme.length === 3 &&
|
|
24050
|
+
(wsComponent.scheme[0] === 'w' || wsComponent.scheme[0] === 'W') &&
|
|
24051
|
+
(wsComponent.scheme[1] === 's' || wsComponent.scheme[1] === 'S') &&
|
|
24052
|
+
(wsComponent.scheme[2] === 's' || wsComponent.scheme[2] === 'S')
|
|
24053
|
+
)
|
|
24054
|
+
} else {
|
|
24055
|
+
return false
|
|
24056
|
+
}
|
|
24057
|
+
}
|
|
24058
|
+
|
|
24059
|
+
/** @type {SchemeFn} */
|
|
24060
|
+
function httpParse (component) {
|
|
24061
|
+
if (!component.host) {
|
|
24062
|
+
component.error = component.error || 'HTTP URIs must have a host.';
|
|
23635
24063
|
}
|
|
23636
24064
|
|
|
23637
|
-
return
|
|
24065
|
+
return component
|
|
23638
24066
|
}
|
|
23639
24067
|
|
|
23640
|
-
|
|
23641
|
-
|
|
24068
|
+
/** @type {SchemeFn} */
|
|
24069
|
+
function httpSerialize (component) {
|
|
24070
|
+
const secure = String(component.scheme).toLowerCase() === 'https';
|
|
23642
24071
|
|
|
23643
24072
|
// normalize the default port
|
|
23644
|
-
if (
|
|
23645
|
-
|
|
24073
|
+
if (component.port === (secure ? 443 : 80) || component.port === '') {
|
|
24074
|
+
component.port = undefined;
|
|
23646
24075
|
}
|
|
23647
24076
|
|
|
23648
24077
|
// normalize the empty path
|
|
23649
|
-
if (!
|
|
23650
|
-
|
|
24078
|
+
if (!component.path) {
|
|
24079
|
+
component.path = '/';
|
|
23651
24080
|
}
|
|
23652
24081
|
|
|
23653
24082
|
// NOTE: We do not parse query strings for HTTP URIs
|
|
23654
24083
|
// as WWW Form Url Encoded query strings are part of the HTML4+ spec,
|
|
23655
24084
|
// and not the HTTP spec.
|
|
23656
24085
|
|
|
23657
|
-
return
|
|
24086
|
+
return component
|
|
23658
24087
|
}
|
|
23659
24088
|
|
|
23660
|
-
|
|
24089
|
+
/** @type {SchemeFn} */
|
|
24090
|
+
function wsParse (wsComponent) {
|
|
23661
24091
|
// indicate if the secure flag is set
|
|
23662
|
-
|
|
24092
|
+
wsComponent.secure = wsIsSecure(wsComponent);
|
|
23663
24093
|
|
|
23664
24094
|
// construct resouce name
|
|
23665
|
-
|
|
23666
|
-
|
|
23667
|
-
|
|
24095
|
+
wsComponent.resourceName = (wsComponent.path || '/') + (wsComponent.query ? '?' + wsComponent.query : '');
|
|
24096
|
+
wsComponent.path = undefined;
|
|
24097
|
+
wsComponent.query = undefined;
|
|
23668
24098
|
|
|
23669
|
-
return
|
|
24099
|
+
return wsComponent
|
|
23670
24100
|
}
|
|
23671
24101
|
|
|
23672
|
-
|
|
24102
|
+
/** @type {SchemeFn} */
|
|
24103
|
+
function wsSerialize (wsComponent) {
|
|
23673
24104
|
// normalize the default port
|
|
23674
|
-
if (
|
|
23675
|
-
|
|
24105
|
+
if (wsComponent.port === (wsIsSecure(wsComponent) ? 443 : 80) || wsComponent.port === '') {
|
|
24106
|
+
wsComponent.port = undefined;
|
|
23676
24107
|
}
|
|
23677
24108
|
|
|
23678
24109
|
// ensure scheme matches secure flag
|
|
23679
|
-
if (typeof
|
|
23680
|
-
|
|
23681
|
-
|
|
24110
|
+
if (typeof wsComponent.secure === 'boolean') {
|
|
24111
|
+
wsComponent.scheme = (wsComponent.secure ? 'wss' : 'ws');
|
|
24112
|
+
wsComponent.secure = undefined;
|
|
23682
24113
|
}
|
|
23683
24114
|
|
|
23684
24115
|
// reconstruct path from resource name
|
|
23685
|
-
if (
|
|
23686
|
-
const [path, query] =
|
|
23687
|
-
|
|
23688
|
-
|
|
23689
|
-
|
|
24116
|
+
if (wsComponent.resourceName) {
|
|
24117
|
+
const [path, query] = wsComponent.resourceName.split('?');
|
|
24118
|
+
wsComponent.path = (path && path !== '/' ? path : undefined);
|
|
24119
|
+
wsComponent.query = query;
|
|
24120
|
+
wsComponent.resourceName = undefined;
|
|
23690
24121
|
}
|
|
23691
24122
|
|
|
23692
24123
|
// forbid fragment component
|
|
23693
|
-
|
|
24124
|
+
wsComponent.fragment = undefined;
|
|
23694
24125
|
|
|
23695
|
-
return
|
|
24126
|
+
return wsComponent
|
|
23696
24127
|
}
|
|
23697
24128
|
|
|
23698
|
-
|
|
23699
|
-
|
|
23700
|
-
|
|
23701
|
-
|
|
24129
|
+
/** @type {SchemeFn} */
|
|
24130
|
+
function urnParse (urnComponent, options) {
|
|
24131
|
+
if (!urnComponent.path) {
|
|
24132
|
+
urnComponent.error = 'URN can not be parsed';
|
|
24133
|
+
return urnComponent
|
|
23702
24134
|
}
|
|
23703
|
-
const matches =
|
|
24135
|
+
const matches = urnComponent.path.match(URN_REG);
|
|
23704
24136
|
if (matches) {
|
|
23705
|
-
const scheme = options.scheme ||
|
|
23706
|
-
|
|
23707
|
-
|
|
23708
|
-
const urnScheme = `${scheme}:${options.nid ||
|
|
23709
|
-
const schemeHandler =
|
|
23710
|
-
|
|
24137
|
+
const scheme = options.scheme || urnComponent.scheme || 'urn';
|
|
24138
|
+
urnComponent.nid = matches[1].toLowerCase();
|
|
24139
|
+
urnComponent.nss = matches[2];
|
|
24140
|
+
const urnScheme = `${scheme}:${options.nid || urnComponent.nid}`;
|
|
24141
|
+
const schemeHandler = getSchemeHandler(urnScheme);
|
|
24142
|
+
urnComponent.path = undefined;
|
|
23711
24143
|
|
|
23712
24144
|
if (schemeHandler) {
|
|
23713
|
-
|
|
24145
|
+
urnComponent = schemeHandler.parse(urnComponent, options);
|
|
23714
24146
|
}
|
|
23715
24147
|
} else {
|
|
23716
|
-
|
|
24148
|
+
urnComponent.error = urnComponent.error || 'URN can not be parsed.';
|
|
23717
24149
|
}
|
|
23718
24150
|
|
|
23719
|
-
return
|
|
24151
|
+
return urnComponent
|
|
23720
24152
|
}
|
|
23721
24153
|
|
|
23722
|
-
|
|
23723
|
-
|
|
23724
|
-
|
|
24154
|
+
/** @type {SchemeFn} */
|
|
24155
|
+
function urnSerialize (urnComponent, options) {
|
|
24156
|
+
if (urnComponent.nid === undefined) {
|
|
24157
|
+
throw new Error('URN without nid cannot be serialized')
|
|
24158
|
+
}
|
|
24159
|
+
const scheme = options.scheme || urnComponent.scheme || 'urn';
|
|
24160
|
+
const nid = urnComponent.nid.toLowerCase();
|
|
23725
24161
|
const urnScheme = `${scheme}:${options.nid || nid}`;
|
|
23726
|
-
const schemeHandler =
|
|
24162
|
+
const schemeHandler = getSchemeHandler(urnScheme);
|
|
23727
24163
|
|
|
23728
24164
|
if (schemeHandler) {
|
|
23729
|
-
|
|
24165
|
+
urnComponent = schemeHandler.serialize(urnComponent, options);
|
|
23730
24166
|
}
|
|
23731
24167
|
|
|
23732
|
-
const
|
|
23733
|
-
const nss =
|
|
23734
|
-
|
|
24168
|
+
const uriComponent = urnComponent;
|
|
24169
|
+
const nss = urnComponent.nss;
|
|
24170
|
+
uriComponent.path = `${nid || options.nid}:${nss}`;
|
|
23735
24171
|
|
|
23736
24172
|
options.skipEscape = true;
|
|
23737
|
-
return
|
|
24173
|
+
return uriComponent
|
|
23738
24174
|
}
|
|
23739
24175
|
|
|
23740
|
-
|
|
23741
|
-
|
|
23742
|
-
|
|
23743
|
-
|
|
24176
|
+
/** @type {SchemeFn} */
|
|
24177
|
+
function urnuuidParse (urnComponent, options) {
|
|
24178
|
+
const uuidComponent = urnComponent;
|
|
24179
|
+
uuidComponent.uuid = uuidComponent.nss;
|
|
24180
|
+
uuidComponent.nss = undefined;
|
|
23744
24181
|
|
|
23745
|
-
if (!options.tolerant && (!
|
|
23746
|
-
|
|
24182
|
+
if (!options.tolerant && (!uuidComponent.uuid || !isUUID(uuidComponent.uuid))) {
|
|
24183
|
+
uuidComponent.error = uuidComponent.error || 'UUID is not valid.';
|
|
23747
24184
|
}
|
|
23748
24185
|
|
|
23749
|
-
return
|
|
24186
|
+
return uuidComponent
|
|
23750
24187
|
}
|
|
23751
24188
|
|
|
23752
|
-
|
|
23753
|
-
|
|
24189
|
+
/** @type {SchemeFn} */
|
|
24190
|
+
function urnuuidSerialize (uuidComponent) {
|
|
24191
|
+
const urnComponent = uuidComponent;
|
|
23754
24192
|
// normalize UUID
|
|
23755
|
-
|
|
23756
|
-
return
|
|
24193
|
+
urnComponent.nss = (uuidComponent.uuid || '').toLowerCase();
|
|
24194
|
+
return urnComponent
|
|
23757
24195
|
}
|
|
23758
24196
|
|
|
23759
|
-
const http = {
|
|
24197
|
+
const http = /** @type {SchemeHandler} */ ({
|
|
23760
24198
|
scheme: 'http',
|
|
23761
24199
|
domainHost: true,
|
|
23762
24200
|
parse: httpParse,
|
|
23763
24201
|
serialize: httpSerialize
|
|
23764
|
-
};
|
|
24202
|
+
});
|
|
23765
24203
|
|
|
23766
|
-
const https = {
|
|
24204
|
+
const https = /** @type {SchemeHandler} */ ({
|
|
23767
24205
|
scheme: 'https',
|
|
23768
24206
|
domainHost: http.domainHost,
|
|
23769
24207
|
parse: httpParse,
|
|
23770
24208
|
serialize: httpSerialize
|
|
23771
|
-
};
|
|
24209
|
+
});
|
|
23772
24210
|
|
|
23773
|
-
const ws = {
|
|
24211
|
+
const ws = /** @type {SchemeHandler} */ ({
|
|
23774
24212
|
scheme: 'ws',
|
|
23775
24213
|
domainHost: true,
|
|
23776
24214
|
parse: wsParse,
|
|
23777
24215
|
serialize: wsSerialize
|
|
23778
|
-
};
|
|
24216
|
+
});
|
|
23779
24217
|
|
|
23780
|
-
const wss = {
|
|
24218
|
+
const wss = /** @type {SchemeHandler} */ ({
|
|
23781
24219
|
scheme: 'wss',
|
|
23782
24220
|
domainHost: ws.domainHost,
|
|
23783
24221
|
parse: ws.parse,
|
|
23784
24222
|
serialize: ws.serialize
|
|
23785
|
-
};
|
|
24223
|
+
});
|
|
23786
24224
|
|
|
23787
|
-
const urn = {
|
|
24225
|
+
const urn = /** @type {SchemeHandler} */ ({
|
|
23788
24226
|
scheme: 'urn',
|
|
23789
24227
|
parse: urnParse,
|
|
23790
24228
|
serialize: urnSerialize,
|
|
23791
24229
|
skipNormalize: true
|
|
23792
|
-
};
|
|
24230
|
+
});
|
|
23793
24231
|
|
|
23794
|
-
const urnuuid = {
|
|
24232
|
+
const urnuuid = /** @type {SchemeHandler} */ ({
|
|
23795
24233
|
scheme: 'urn:uuid',
|
|
23796
24234
|
parse: urnuuidParse,
|
|
23797
24235
|
serialize: urnuuidSerialize,
|
|
23798
24236
|
skipNormalize: true
|
|
23799
|
-
};
|
|
24237
|
+
});
|
|
23800
24238
|
|
|
23801
|
-
const SCHEMES = {
|
|
24239
|
+
const SCHEMES = /** @type {Record<SchemeName, SchemeHandler>} */ ({
|
|
23802
24240
|
http,
|
|
23803
24241
|
https,
|
|
23804
24242
|
ws,
|
|
23805
24243
|
wss,
|
|
23806
24244
|
urn,
|
|
23807
24245
|
'urn:uuid': urnuuid
|
|
23808
|
-
};
|
|
24246
|
+
});
|
|
23809
24247
|
|
|
23810
|
-
|
|
24248
|
+
Object.setPrototypeOf(SCHEMES, null);
|
|
24249
|
+
|
|
24250
|
+
/**
|
|
24251
|
+
* @param {string|undefined} scheme
|
|
24252
|
+
* @returns {SchemeHandler|undefined}
|
|
24253
|
+
*/
|
|
24254
|
+
function getSchemeHandler (scheme) {
|
|
24255
|
+
return (
|
|
24256
|
+
scheme && (
|
|
24257
|
+
SCHEMES[/** @type {SchemeName} */ (scheme)] ||
|
|
24258
|
+
SCHEMES[/** @type {SchemeName} */(scheme.toLowerCase())])
|
|
24259
|
+
) ||
|
|
24260
|
+
undefined
|
|
24261
|
+
}
|
|
24262
|
+
|
|
24263
|
+
schemes = {
|
|
24264
|
+
wsIsSecure,
|
|
24265
|
+
SCHEMES,
|
|
24266
|
+
isValidSchemeName,
|
|
24267
|
+
getSchemeHandler,
|
|
24268
|
+
};
|
|
23811
24269
|
return schemes;
|
|
23812
24270
|
}
|
|
23813
24271
|
|
|
@@ -23817,29 +24275,50 @@ function requireFastUri () {
|
|
|
23817
24275
|
if (hasRequiredFastUri) return fastUri.exports;
|
|
23818
24276
|
hasRequiredFastUri = 1;
|
|
23819
24277
|
|
|
23820
|
-
const { normalizeIPv6,
|
|
23821
|
-
const SCHEMES = requireSchemes();
|
|
24278
|
+
const { normalizeIPv6, removeDotSegments, recomposeAuthority, normalizeComponentEncoding, isIPv4, nonSimpleDomain } = requireUtils();
|
|
24279
|
+
const { SCHEMES, getSchemeHandler } = requireSchemes();
|
|
23822
24280
|
|
|
24281
|
+
/**
|
|
24282
|
+
* @template {import('./types/index').URIComponent|string} T
|
|
24283
|
+
* @param {T} uri
|
|
24284
|
+
* @param {import('./types/index').Options} [options]
|
|
24285
|
+
* @returns {T}
|
|
24286
|
+
*/
|
|
23823
24287
|
function normalize (uri, options) {
|
|
23824
24288
|
if (typeof uri === 'string') {
|
|
23825
|
-
uri = serialize(parse(uri, options), options);
|
|
24289
|
+
uri = /** @type {T} */ (serialize(parse(uri, options), options));
|
|
23826
24290
|
} else if (typeof uri === 'object') {
|
|
23827
|
-
uri = parse(serialize(uri, options), options);
|
|
24291
|
+
uri = /** @type {T} */ (parse(serialize(uri, options), options));
|
|
23828
24292
|
}
|
|
23829
24293
|
return uri
|
|
23830
24294
|
}
|
|
23831
24295
|
|
|
24296
|
+
/**
|
|
24297
|
+
* @param {string} baseURI
|
|
24298
|
+
* @param {string} relativeURI
|
|
24299
|
+
* @param {import('./types/index').Options} [options]
|
|
24300
|
+
* @returns {string}
|
|
24301
|
+
*/
|
|
23832
24302
|
function resolve (baseURI, relativeURI, options) {
|
|
23833
|
-
const schemelessOptions = Object.assign({ scheme: 'null' }, options);
|
|
23834
|
-
const resolved =
|
|
23835
|
-
|
|
24303
|
+
const schemelessOptions = options ? Object.assign({ scheme: 'null' }, options) : { scheme: 'null' };
|
|
24304
|
+
const resolved = resolveComponent(parse(baseURI, schemelessOptions), parse(relativeURI, schemelessOptions), schemelessOptions, true);
|
|
24305
|
+
schemelessOptions.skipEscape = true;
|
|
24306
|
+
return serialize(resolved, schemelessOptions)
|
|
23836
24307
|
}
|
|
23837
24308
|
|
|
23838
|
-
|
|
24309
|
+
/**
|
|
24310
|
+
* @param {import ('./types/index').URIComponent} base
|
|
24311
|
+
* @param {import ('./types/index').URIComponent} relative
|
|
24312
|
+
* @param {import('./types/index').Options} [options]
|
|
24313
|
+
* @param {boolean} [skipNormalization=false]
|
|
24314
|
+
* @returns {import ('./types/index').URIComponent}
|
|
24315
|
+
*/
|
|
24316
|
+
function resolveComponent (base, relative, options, skipNormalization) {
|
|
24317
|
+
/** @type {import('./types/index').URIComponent} */
|
|
23839
24318
|
const target = {};
|
|
23840
24319
|
if (!skipNormalization) {
|
|
23841
|
-
base = parse(serialize(base, options), options); // normalize base
|
|
23842
|
-
relative = parse(serialize(relative, options), options); // normalize relative
|
|
24320
|
+
base = parse(serialize(base, options), options); // normalize base component
|
|
24321
|
+
relative = parse(serialize(relative, options), options); // normalize relative component
|
|
23843
24322
|
}
|
|
23844
24323
|
options = options || {};
|
|
23845
24324
|
|
|
@@ -23868,7 +24347,7 @@ function requireFastUri () {
|
|
|
23868
24347
|
target.query = base.query;
|
|
23869
24348
|
}
|
|
23870
24349
|
} else {
|
|
23871
|
-
if (relative.path
|
|
24350
|
+
if (relative.path[0] === '/') {
|
|
23872
24351
|
target.path = removeDotSegments(relative.path);
|
|
23873
24352
|
} else {
|
|
23874
24353
|
if ((base.userinfo !== undefined || base.host !== undefined || base.port !== undefined) && !base.path) {
|
|
@@ -23895,6 +24374,12 @@ function requireFastUri () {
|
|
|
23895
24374
|
return target
|
|
23896
24375
|
}
|
|
23897
24376
|
|
|
24377
|
+
/**
|
|
24378
|
+
* @param {import ('./types/index').URIComponent|string} uriA
|
|
24379
|
+
* @param {import ('./types/index').URIComponent|string} uriB
|
|
24380
|
+
* @param {import ('./types/index').Options} options
|
|
24381
|
+
* @returns {boolean}
|
|
24382
|
+
*/
|
|
23898
24383
|
function equal (uriA, uriB, options) {
|
|
23899
24384
|
if (typeof uriA === 'string') {
|
|
23900
24385
|
uriA = unescape(uriA);
|
|
@@ -23913,8 +24398,13 @@ function requireFastUri () {
|
|
|
23913
24398
|
return uriA.toLowerCase() === uriB.toLowerCase()
|
|
23914
24399
|
}
|
|
23915
24400
|
|
|
24401
|
+
/**
|
|
24402
|
+
* @param {Readonly<import('./types/index').URIComponent>} cmpts
|
|
24403
|
+
* @param {import('./types/index').Options} [opts]
|
|
24404
|
+
* @returns {string}
|
|
24405
|
+
*/
|
|
23916
24406
|
function serialize (cmpts, opts) {
|
|
23917
|
-
const
|
|
24407
|
+
const component = {
|
|
23918
24408
|
host: cmpts.host,
|
|
23919
24409
|
scheme: cmpts.scheme,
|
|
23920
24410
|
userinfo: cmpts.userinfo,
|
|
@@ -23934,28 +24424,28 @@ function requireFastUri () {
|
|
|
23934
24424
|
const uriTokens = [];
|
|
23935
24425
|
|
|
23936
24426
|
// find scheme handler
|
|
23937
|
-
const schemeHandler =
|
|
24427
|
+
const schemeHandler = getSchemeHandler(options.scheme || component.scheme);
|
|
23938
24428
|
|
|
23939
24429
|
// perform scheme specific serialization
|
|
23940
|
-
if (schemeHandler && schemeHandler.serialize) schemeHandler.serialize(
|
|
24430
|
+
if (schemeHandler && schemeHandler.serialize) schemeHandler.serialize(component, options);
|
|
23941
24431
|
|
|
23942
|
-
if (
|
|
24432
|
+
if (component.path !== undefined) {
|
|
23943
24433
|
if (!options.skipEscape) {
|
|
23944
|
-
|
|
24434
|
+
component.path = escape(component.path);
|
|
23945
24435
|
|
|
23946
|
-
if (
|
|
23947
|
-
|
|
24436
|
+
if (component.scheme !== undefined) {
|
|
24437
|
+
component.path = component.path.split('%3A').join(':');
|
|
23948
24438
|
}
|
|
23949
24439
|
} else {
|
|
23950
|
-
|
|
24440
|
+
component.path = unescape(component.path);
|
|
23951
24441
|
}
|
|
23952
24442
|
}
|
|
23953
24443
|
|
|
23954
|
-
if (options.reference !== 'suffix' &&
|
|
23955
|
-
uriTokens.push(
|
|
24444
|
+
if (options.reference !== 'suffix' && component.scheme) {
|
|
24445
|
+
uriTokens.push(component.scheme, ':');
|
|
23956
24446
|
}
|
|
23957
24447
|
|
|
23958
|
-
const authority = recomposeAuthority(
|
|
24448
|
+
const authority = recomposeAuthority(component);
|
|
23959
24449
|
if (authority !== undefined) {
|
|
23960
24450
|
if (options.reference !== 'suffix') {
|
|
23961
24451
|
uriTokens.push('//');
|
|
@@ -23963,51 +24453,49 @@ function requireFastUri () {
|
|
|
23963
24453
|
|
|
23964
24454
|
uriTokens.push(authority);
|
|
23965
24455
|
|
|
23966
|
-
if (
|
|
24456
|
+
if (component.path && component.path[0] !== '/') {
|
|
23967
24457
|
uriTokens.push('/');
|
|
23968
24458
|
}
|
|
23969
24459
|
}
|
|
23970
|
-
if (
|
|
23971
|
-
let s =
|
|
24460
|
+
if (component.path !== undefined) {
|
|
24461
|
+
let s = component.path;
|
|
23972
24462
|
|
|
23973
24463
|
if (!options.absolutePath && (!schemeHandler || !schemeHandler.absolutePath)) {
|
|
23974
24464
|
s = removeDotSegments(s);
|
|
23975
24465
|
}
|
|
23976
24466
|
|
|
23977
|
-
if (
|
|
23978
|
-
|
|
24467
|
+
if (
|
|
24468
|
+
authority === undefined &&
|
|
24469
|
+
s[0] === '/' &&
|
|
24470
|
+
s[1] === '/'
|
|
24471
|
+
) {
|
|
24472
|
+
// don't allow the path to start with "//"
|
|
24473
|
+
s = '/%2F' + s.slice(2);
|
|
23979
24474
|
}
|
|
23980
24475
|
|
|
23981
24476
|
uriTokens.push(s);
|
|
23982
24477
|
}
|
|
23983
24478
|
|
|
23984
|
-
if (
|
|
23985
|
-
uriTokens.push('?',
|
|
24479
|
+
if (component.query !== undefined) {
|
|
24480
|
+
uriTokens.push('?', component.query);
|
|
23986
24481
|
}
|
|
23987
24482
|
|
|
23988
|
-
if (
|
|
23989
|
-
uriTokens.push('#',
|
|
24483
|
+
if (component.fragment !== undefined) {
|
|
24484
|
+
uriTokens.push('#', component.fragment);
|
|
23990
24485
|
}
|
|
23991
24486
|
return uriTokens.join('')
|
|
23992
24487
|
}
|
|
23993
24488
|
|
|
23994
|
-
const hexLookUp = Array.from({ length: 127 }, (_v, k) => /[^!"$&'()*+,\-.;=_`a-z{}~]/u.test(String.fromCharCode(k)));
|
|
23995
|
-
|
|
23996
|
-
function nonSimpleDomain (value) {
|
|
23997
|
-
let code = 0;
|
|
23998
|
-
for (let i = 0, len = value.length; i < len; ++i) {
|
|
23999
|
-
code = value.charCodeAt(i);
|
|
24000
|
-
if (code > 126 || hexLookUp[code]) {
|
|
24001
|
-
return true
|
|
24002
|
-
}
|
|
24003
|
-
}
|
|
24004
|
-
return false
|
|
24005
|
-
}
|
|
24006
|
-
|
|
24007
24489
|
const URI_PARSE = /^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;
|
|
24008
24490
|
|
|
24491
|
+
/**
|
|
24492
|
+
* @param {string} uri
|
|
24493
|
+
* @param {import('./types/index').Options} [opts]
|
|
24494
|
+
* @returns
|
|
24495
|
+
*/
|
|
24009
24496
|
function parse (uri, opts) {
|
|
24010
24497
|
const options = Object.assign({}, opts);
|
|
24498
|
+
/** @type {import('./types/index').URIComponent} */
|
|
24011
24499
|
const parsed = {
|
|
24012
24500
|
scheme: undefined,
|
|
24013
24501
|
userinfo: undefined,
|
|
@@ -24017,9 +24505,15 @@ function requireFastUri () {
|
|
|
24017
24505
|
query: undefined,
|
|
24018
24506
|
fragment: undefined
|
|
24019
24507
|
};
|
|
24020
|
-
|
|
24508
|
+
|
|
24021
24509
|
let isIP = false;
|
|
24022
|
-
if (options.reference === 'suffix')
|
|
24510
|
+
if (options.reference === 'suffix') {
|
|
24511
|
+
if (options.scheme) {
|
|
24512
|
+
uri = options.scheme + ':' + uri;
|
|
24513
|
+
} else {
|
|
24514
|
+
uri = '//' + uri;
|
|
24515
|
+
}
|
|
24516
|
+
}
|
|
24023
24517
|
|
|
24024
24518
|
const matches = uri.match(URI_PARSE);
|
|
24025
24519
|
|
|
@@ -24038,13 +24532,12 @@ function requireFastUri () {
|
|
|
24038
24532
|
parsed.port = matches[5];
|
|
24039
24533
|
}
|
|
24040
24534
|
if (parsed.host) {
|
|
24041
|
-
const ipv4result =
|
|
24042
|
-
if (ipv4result
|
|
24043
|
-
const ipv6result = normalizeIPv6(
|
|
24535
|
+
const ipv4result = isIPv4(parsed.host);
|
|
24536
|
+
if (ipv4result === false) {
|
|
24537
|
+
const ipv6result = normalizeIPv6(parsed.host);
|
|
24044
24538
|
parsed.host = ipv6result.host.toLowerCase();
|
|
24045
24539
|
isIP = ipv6result.isIPV6;
|
|
24046
24540
|
} else {
|
|
24047
|
-
parsed.host = ipv4result.host;
|
|
24048
24541
|
isIP = true;
|
|
24049
24542
|
}
|
|
24050
24543
|
}
|
|
@@ -24064,7 +24557,7 @@ function requireFastUri () {
|
|
|
24064
24557
|
}
|
|
24065
24558
|
|
|
24066
24559
|
// find scheme handler
|
|
24067
|
-
const schemeHandler =
|
|
24560
|
+
const schemeHandler = getSchemeHandler(options.scheme || parsed.scheme);
|
|
24068
24561
|
|
|
24069
24562
|
// check if scheme can't handle IRIs
|
|
24070
24563
|
if (!options.unicodeSupport && (!schemeHandler || !schemeHandler.unicodeSupport)) {
|
|
@@ -24081,11 +24574,13 @@ function requireFastUri () {
|
|
|
24081
24574
|
}
|
|
24082
24575
|
|
|
24083
24576
|
if (!schemeHandler || (schemeHandler && !schemeHandler.skipNormalize)) {
|
|
24084
|
-
if (
|
|
24085
|
-
parsed.scheme
|
|
24086
|
-
|
|
24087
|
-
|
|
24088
|
-
parsed.host
|
|
24577
|
+
if (uri.indexOf('%') !== -1) {
|
|
24578
|
+
if (parsed.scheme !== undefined) {
|
|
24579
|
+
parsed.scheme = unescape(parsed.scheme);
|
|
24580
|
+
}
|
|
24581
|
+
if (parsed.host !== undefined) {
|
|
24582
|
+
parsed.host = unescape(parsed.host);
|
|
24583
|
+
}
|
|
24089
24584
|
}
|
|
24090
24585
|
if (parsed.path) {
|
|
24091
24586
|
parsed.path = escape(unescape(parsed.path));
|
|
@@ -24109,7 +24604,7 @@ function requireFastUri () {
|
|
|
24109
24604
|
SCHEMES,
|
|
24110
24605
|
normalize,
|
|
24111
24606
|
resolve,
|
|
24112
|
-
|
|
24607
|
+
resolveComponent,
|
|
24113
24608
|
equal,
|
|
24114
24609
|
serialize,
|
|
24115
24610
|
parse
|
|
@@ -32057,7 +32552,7 @@ class Comparator {
|
|
|
32057
32552
|
}
|
|
32058
32553
|
}
|
|
32059
32554
|
|
|
32060
|
-
var version = "1.
|
|
32555
|
+
var version = "1.7.0";
|
|
32061
32556
|
var packageJson = {
|
|
32062
32557
|
version: version};
|
|
32063
32558
|
|