@zuplo/cli 6.71.15 → 6.71.17
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/node_modules/@types/node/README.md +1 -1
- package/node_modules/@types/node/diagnostics_channel.d.ts +17 -20
- package/node_modules/@types/node/package.json +2 -2
- package/node_modules/@zuplo/core/package.json +1 -1
- package/node_modules/@zuplo/graphql/package.json +1 -1
- package/node_modules/@zuplo/openapi-tools/package.json +1 -1
- package/node_modules/@zuplo/otel/out/esm/{chunk-DG5SQS54.js → chunk-T25G5RDX.js} +2 -2
- package/node_modules/@zuplo/otel/out/esm/{chunk-DG5SQS54.js.map → chunk-T25G5RDX.js.map} +1 -1
- package/node_modules/@zuplo/otel/out/esm/index.js +1 -1
- package/node_modules/@zuplo/otel/out/types/index.d.ts +6 -3
- package/node_modules/@zuplo/otel/package.json +1 -1
- package/node_modules/@zuplo/runtime/package.json +1 -1
- package/node_modules/qs/CHANGELOG.md +11 -0
- package/node_modules/qs/dist/qs.js +17 -17
- package/node_modules/qs/lib/parse.js +19 -8
- package/node_modules/qs/lib/utils.js +47 -8
- package/node_modules/qs/package.json +6 -5
- package/node_modules/qs/test/parse.js +230 -0
- package/node_modules/qs/test/utils.js +194 -0
- package/package.json +6 -6
|
@@ -14,6 +14,12 @@ var hasProto = require('has-proto')();
|
|
|
14
14
|
var qs = require('../');
|
|
15
15
|
var utils = require('../lib/utils');
|
|
16
16
|
|
|
17
|
+
var characterizeParse = function characterizeParse(st, input, opts, expected, label) {
|
|
18
|
+
var result;
|
|
19
|
+
st.doesNotThrow(function () { result = qs.parse(input, opts); }, label + ': does not throw');
|
|
20
|
+
st.deepEqual(result, expected, label + ': parses to the current lenient output');
|
|
21
|
+
};
|
|
22
|
+
|
|
17
23
|
test('parse()', function (t) {
|
|
18
24
|
t.test('parses a simple string', function (st) {
|
|
19
25
|
st.deepEqual(qs.parse('0=foo'), { 0: 'foo' });
|
|
@@ -312,6 +318,48 @@ test('parse()', function (t) {
|
|
|
312
318
|
st.end();
|
|
313
319
|
});
|
|
314
320
|
|
|
321
|
+
t.test('currently parses unbalanced bracket keys after a parent leniently to literal segments (issue #558)', function (st) {
|
|
322
|
+
characterizeParse(st, 'a[bc=v', undefined, { a: { '[bc': 'v' } }, 'unclosed group after a parent');
|
|
323
|
+
characterizeParse(st, 'a[=v', undefined, { a: { '[': 'v' } }, 'bare unclosed bracket after a parent');
|
|
324
|
+
characterizeParse(st, 'a[b][c=v', undefined, { a: { b: { '[c': 'v' } } }, 'unclosed group after a valid one');
|
|
325
|
+
characterizeParse(st, 'a[b]c[d=v', undefined, { a: { b: { '[d': 'v' } } }, 'unclosed group after text following a valid one');
|
|
326
|
+
characterizeParse(st, 'filters[customtags:Env: Prod=v', undefined, { filters: { '[customtags:Env: Prod': 'v' } }, 'the issue #558 reproduction');
|
|
327
|
+
characterizeParse(st, '][a=v', undefined, { ']': { '[a': 'v' } }, 'stray close bracket before an unclosed group');
|
|
328
|
+
characterizeParse(st, 'a][b=v', undefined, { 'a]': { '[b': 'v' } }, 'stray close bracket inside the parent');
|
|
329
|
+
st.end();
|
|
330
|
+
});
|
|
331
|
+
|
|
332
|
+
t.test('currently parses unbalanced bracket keys containing inner brackets leniently (issue #558)', function (st) {
|
|
333
|
+
characterizeParse(st, 'a[b[c=v', undefined, { a: { '[b[c': 'v' } }, 'unclosed group containing an inner bracket');
|
|
334
|
+
characterizeParse(st, 'a[b[c]=v', undefined, { a: { '[b[c]': 'v' } }, 'unbalanced group with an inner bracket and one close');
|
|
335
|
+
characterizeParse(st, 'a[b][c[d=v', undefined, { a: { b: { '[c[d': 'v' } } }, 'unclosed inner-bracket group after a valid one');
|
|
336
|
+
st.end();
|
|
337
|
+
});
|
|
338
|
+
|
|
339
|
+
t.test('currently parses bracket-prefixed unbalanced keys leniently (issue #558)', function (st) {
|
|
340
|
+
characterizeParse(st, '[abc=v', undefined, { '[abc': 'v' }, 'key starting with an unclosed bracket');
|
|
341
|
+
characterizeParse(st, '[[]b=v', undefined, { '[[]b': 'v' }, 'key starting with an unbalanced bracket group');
|
|
342
|
+
st.end();
|
|
343
|
+
});
|
|
344
|
+
|
|
345
|
+
t.test('lenient unbalanced-bracket handling currently depends on the depth option (issue #558)', function (st) {
|
|
346
|
+
characterizeParse(st, 'a[b]c[d]e[f=v', { depth: 5 }, { a: { b: { d: { '[f': 'v' } } } }, 'consumes groups up to the depth budget then keeps the unclosed remainder literal');
|
|
347
|
+
characterizeParse(st, 'a[b]c[d]e[f=v', { depth: 1 }, { a: { b: { '[d]e[f': 'v' } } }, 'a lower depth keeps more of the unclosed remainder literal');
|
|
348
|
+
characterizeParse(st, 'a[bc=v', { depth: 0 }, { 'a[bc': 'v' }, 'depth 0 keeps the entire key literal');
|
|
349
|
+
st.end();
|
|
350
|
+
});
|
|
351
|
+
|
|
352
|
+
t.test('currently parses an allowDots key with a trailing unclosed bracket leniently (issue #558)', function (st) {
|
|
353
|
+
characterizeParse(st, 'a.b[c=v', { allowDots: true }, { a: { b: { '[c': 'v' } } }, 'allowDots expands the dot then keeps the unclosed bracket literal');
|
|
354
|
+
st.end();
|
|
355
|
+
});
|
|
356
|
+
|
|
357
|
+
t.test('valid and stray-close bracket keys are unaffected by unbalanced-bracket handling', function (st) {
|
|
358
|
+
characterizeParse(st, 'a]b=v', undefined, { 'a]b': 'v' }, 'stray close bracket with no open bracket stays a flat key');
|
|
359
|
+
characterizeParse(st, 'a[b]extra=v', undefined, { a: { b: 'v' } }, 'text after a balanced group is ignored');
|
|
360
|
+
st.end();
|
|
361
|
+
});
|
|
362
|
+
|
|
315
363
|
t.test('allows to specify array indices', function (st) {
|
|
316
364
|
st.deepEqual(qs.parse('a[1]=c&a[0]=b&a[2]=d'), { a: ['b', 'c', 'd'] });
|
|
317
365
|
st.deepEqual(qs.parse('a[1]=c&a[0]=b'), { a: ['b', 'c'] });
|
|
@@ -726,6 +774,21 @@ test('parse()', function (t) {
|
|
|
726
774
|
st.end();
|
|
727
775
|
});
|
|
728
776
|
|
|
777
|
+
t.test('does not crash on multi-step circular references', function (st) {
|
|
778
|
+
var a = {};
|
|
779
|
+
a.b = { c: { d: a } };
|
|
780
|
+
|
|
781
|
+
var parsed;
|
|
782
|
+
|
|
783
|
+
st.doesNotThrow(function () {
|
|
784
|
+
parsed = qs.parse({ foo: a });
|
|
785
|
+
});
|
|
786
|
+
|
|
787
|
+
st.equal('foo' in parsed, true, 'parsed has "foo" property');
|
|
788
|
+
st.equal(parsed.foo.b.c.d, parsed.foo, 'the multi-step cycle is preserved');
|
|
789
|
+
st.end();
|
|
790
|
+
});
|
|
791
|
+
|
|
729
792
|
t.test('does not crash when parsing deep objects', function (st) {
|
|
730
793
|
var parsed;
|
|
731
794
|
var str = 'foo';
|
|
@@ -959,6 +1022,22 @@ test('parse()', function (t) {
|
|
|
959
1022
|
st.end();
|
|
960
1023
|
});
|
|
961
1024
|
|
|
1025
|
+
t.test('object-valued input with own `__proto__` does not mutate sub-object [[Prototype]]', function (st) {
|
|
1026
|
+
// JSON.parse creates own data `__proto__` properties (via CreateDataProperty),
|
|
1027
|
+
// which would trigger the Object.prototype.__proto__ accessor if merged via `acc[key] = value`.
|
|
1028
|
+
var out = qs.parse({
|
|
1029
|
+
'user[name]': 'alice',
|
|
1030
|
+
user: JSON.parse('{"__proto__":{"isAdmin":true}}')
|
|
1031
|
+
}, { allowPrototypes: false });
|
|
1032
|
+
|
|
1033
|
+
st.equal(out.user.name, 'alice', 'name from bracket key is preserved');
|
|
1034
|
+
st.equal(out.user.isAdmin, undefined, 'attacker-controlled inherited property is not exposed');
|
|
1035
|
+
st.equal(Object.getPrototypeOf(out.user), Object.prototype, 'sub-object [[Prototype]] is unchanged');
|
|
1036
|
+
st.equal(Object.prototype.isAdmin, undefined, 'Object.prototype is not polluted');
|
|
1037
|
+
|
|
1038
|
+
st.end();
|
|
1039
|
+
});
|
|
1040
|
+
|
|
962
1041
|
t.test('can return null objects', { skip: !hasProto }, function (st) {
|
|
963
1042
|
var expected = {
|
|
964
1043
|
__proto__: null,
|
|
@@ -1309,6 +1388,157 @@ test('parse()', function (t) {
|
|
|
1309
1388
|
sst.end();
|
|
1310
1389
|
});
|
|
1311
1390
|
|
|
1391
|
+
st.test('throws when cumulative comma + duplicate-key combine exceeds arrayLimit', function (sst) {
|
|
1392
|
+
sst['throws'](
|
|
1393
|
+
function () {
|
|
1394
|
+
qs.parse('a=1,2,3&a=4,5,6', { comma: true, arrayLimit: 5, throwOnLimitExceeded: true });
|
|
1395
|
+
},
|
|
1396
|
+
new RangeError('Array limit exceeded. Only 5 elements allowed in an array.'),
|
|
1397
|
+
'throws when comma groups within the limit cumulatively exceed it across duplicate keys'
|
|
1398
|
+
);
|
|
1399
|
+
|
|
1400
|
+
sst['throws'](
|
|
1401
|
+
function () {
|
|
1402
|
+
qs.parse('a=v,v,v,v,v&a=v,v,v,v,v&a=v,v,v,v,v', { comma: true, arrayLimit: 5, throwOnLimitExceeded: true });
|
|
1403
|
+
},
|
|
1404
|
+
new RangeError('Array limit exceeded. Only 5 elements allowed in an array.'),
|
|
1405
|
+
'throws on a subsequent part once the cumulative array is already over the limit'
|
|
1406
|
+
);
|
|
1407
|
+
sst.end();
|
|
1408
|
+
});
|
|
1409
|
+
|
|
1410
|
+
st.test('throws when plain duplicate keys combine past arrayLimit at the boundary', function (sst) {
|
|
1411
|
+
sst['throws'](
|
|
1412
|
+
function () { qs.parse('a=x&a=y', { arrayLimit: 1, throwOnLimitExceeded: true }); },
|
|
1413
|
+
new RangeError('Array limit exceeded. Only 1 element allowed in an array.'),
|
|
1414
|
+
'duplicate scalar keys'
|
|
1415
|
+
);
|
|
1416
|
+
|
|
1417
|
+
sst['throws'](
|
|
1418
|
+
function () { qs.parse('a[]=x&a[]=y', { arrayLimit: 1, throwOnLimitExceeded: true }); },
|
|
1419
|
+
new RangeError('Array limit exceeded. Only 1 element allowed in an array.'),
|
|
1420
|
+
'duplicate bracket keys'
|
|
1421
|
+
);
|
|
1422
|
+
sst.end();
|
|
1423
|
+
});
|
|
1424
|
+
|
|
1425
|
+
st.test('throws when mixed index and key notation merge past arrayLimit', function (sst) {
|
|
1426
|
+
sst['throws'](
|
|
1427
|
+
function () { qs.parse('a=x&a[0]=y', { arrayLimit: 1, throwOnLimitExceeded: true }); },
|
|
1428
|
+
new RangeError('Array limit exceeded. Only 1 element allowed in an array.'),
|
|
1429
|
+
'scalar then index that overflows on merge'
|
|
1430
|
+
);
|
|
1431
|
+
|
|
1432
|
+
sst['throws'](
|
|
1433
|
+
function () { qs.parse('a[0]=1&a[1]=2&a=3', { arrayLimit: 1, throwOnLimitExceeded: true }); },
|
|
1434
|
+
new RangeError('Array limit exceeded. Only 1 element allowed in an array.'),
|
|
1435
|
+
'indexed array then scalar that overflows on merge'
|
|
1436
|
+
);
|
|
1437
|
+
sst.end();
|
|
1438
|
+
});
|
|
1439
|
+
|
|
1440
|
+
st.test('enforces arrayLimit on merge at the boundary, consistently with combine', function (sst) {
|
|
1441
|
+
sst['throws'](
|
|
1442
|
+
function () { qs.parse('a[0]=x&a=y', { arrayLimit: 1, throwOnLimitExceeded: true }); },
|
|
1443
|
+
new RangeError('Array limit exceeded. Only 1 element allowed in an array.'),
|
|
1444
|
+
'a trailing scalar merged into an at-limit array throws'
|
|
1445
|
+
);
|
|
1446
|
+
sst.deepEqual(
|
|
1447
|
+
qs.parse('a[0]=x&a=y', { arrayLimit: 1 }),
|
|
1448
|
+
{ a: { 0: 'x', 1: 'y' } },
|
|
1449
|
+
'and converts to an overflow object without throwOnLimitExceeded'
|
|
1450
|
+
);
|
|
1451
|
+
|
|
1452
|
+
sst['throws'](
|
|
1453
|
+
function () { qs.parse('a[0]=x&a[]=y', { arrayLimit: 1, throwOnLimitExceeded: true }); },
|
|
1454
|
+
new RangeError('Array limit exceeded. Only 1 element allowed in an array.'),
|
|
1455
|
+
'mixed index and bracket notation merged past the limit throws'
|
|
1456
|
+
);
|
|
1457
|
+
sst.deepEqual(
|
|
1458
|
+
qs.parse('a[0]=x&a[]=y', { arrayLimit: 1 }),
|
|
1459
|
+
{ a: { 0: 'x', 1: 'y' } },
|
|
1460
|
+
'mixed index and bracket notation converts like duplicate-bracket combine'
|
|
1461
|
+
);
|
|
1462
|
+
|
|
1463
|
+
sst.end();
|
|
1464
|
+
});
|
|
1465
|
+
|
|
1466
|
+
st.test('does not throw when cumulative comma combine stays within arrayLimit', function (sst) {
|
|
1467
|
+
var result = qs.parse('a=1,2,3&a=4', { comma: true, arrayLimit: 5, throwOnLimitExceeded: true });
|
|
1468
|
+
sst.deepEqual(result, { a: ['1', '2', '3', '4'] }, 'combined array within limit is preserved');
|
|
1469
|
+
sst.end();
|
|
1470
|
+
});
|
|
1471
|
+
|
|
1472
|
+
st.test('silently combines to an overflow object when throwOnLimitExceeded is not set', function (sst) {
|
|
1473
|
+
var result = qs.parse('a=1,2,3&a=4,5,6', { comma: true, arrayLimit: 5 });
|
|
1474
|
+
sst.deepEqual(result, { a: { 0: '1', 1: '2', 2: '3', 3: '4', 4: '5', 5: '6' } }, 'converts to object without throwing');
|
|
1475
|
+
sst.end();
|
|
1476
|
+
});
|
|
1477
|
+
|
|
1478
|
+
st.test('does not throw for comma groups nested under bracket notation, counting each group as one element', function (sst) {
|
|
1479
|
+
var result = qs.parse('a[]=1,2,3&a[]=4,5,6', { comma: true, arrayLimit: 5, throwOnLimitExceeded: true });
|
|
1480
|
+
sst.deepEqual(result, { a: [['1', '2', '3'], ['4', '5', '6']] }, 'nested comma groups count as one element each');
|
|
1481
|
+
sst.end();
|
|
1482
|
+
});
|
|
1483
|
+
|
|
1484
|
+
st.test('throws before splitting when a single comma value exceeds arrayLimit', function (sst) {
|
|
1485
|
+
sst['throws'](
|
|
1486
|
+
function () {
|
|
1487
|
+
qs.parse('a=1,2,3,4,5,6', { comma: true, arrayLimit: 5, throwOnLimitExceeded: true });
|
|
1488
|
+
},
|
|
1489
|
+
new RangeError('Array limit exceeded. Only 5 elements allowed in an array.'),
|
|
1490
|
+
'a flat comma value over the limit throws'
|
|
1491
|
+
);
|
|
1492
|
+
|
|
1493
|
+
sst['throws'](
|
|
1494
|
+
function () {
|
|
1495
|
+
qs.parse('a=1,2', { comma: true, arrayLimit: 1, throwOnLimitExceeded: true });
|
|
1496
|
+
},
|
|
1497
|
+
new RangeError('Array limit exceeded. Only 1 element allowed in an array.'),
|
|
1498
|
+
'singular message at arrayLimit 1'
|
|
1499
|
+
);
|
|
1500
|
+
|
|
1501
|
+
sst['throws'](
|
|
1502
|
+
function () {
|
|
1503
|
+
qs.parse('a[b]=1,2,3,4,5,6', { comma: true, arrayLimit: 5, throwOnLimitExceeded: true });
|
|
1504
|
+
},
|
|
1505
|
+
new RangeError('Array limit exceeded. Only 5 elements allowed in an array.'),
|
|
1506
|
+
'a non-bracket nested key comma value over the limit throws'
|
|
1507
|
+
);
|
|
1508
|
+
sst.end();
|
|
1509
|
+
});
|
|
1510
|
+
|
|
1511
|
+
st.test('does not throw for a single comma value within arrayLimit', function (sst) {
|
|
1512
|
+
sst.deepEqual(
|
|
1513
|
+
qs.parse('a=1,2,3', { comma: true, arrayLimit: 5, throwOnLimitExceeded: true }),
|
|
1514
|
+
{ a: ['1', '2', '3'] },
|
|
1515
|
+
'within the limit'
|
|
1516
|
+
);
|
|
1517
|
+
sst.deepEqual(
|
|
1518
|
+
qs.parse('a=1,2,3,4,5', { comma: true, arrayLimit: 5, throwOnLimitExceeded: true }),
|
|
1519
|
+
{ a: ['1', '2', '3', '4', '5'] },
|
|
1520
|
+
'exactly at the limit'
|
|
1521
|
+
);
|
|
1522
|
+
sst.end();
|
|
1523
|
+
});
|
|
1524
|
+
|
|
1525
|
+
st.test('does not throw for a bracketed comma group within arrayLimit', function (sst) {
|
|
1526
|
+
var result = qs.parse('a[]=1,2,3,4,5,6', { comma: true, arrayLimit: 5, throwOnLimitExceeded: true });
|
|
1527
|
+
sst.deepEqual(result, { a: [['1', '2', '3', '4', '5', '6']] }, 'a bracketed comma group is a single element');
|
|
1528
|
+
sst.end();
|
|
1529
|
+
});
|
|
1530
|
+
|
|
1531
|
+
st.test('throws for a bracketed comma group when arrayLimit is 0', function (sst) {
|
|
1532
|
+
sst['throws'](
|
|
1533
|
+
function () {
|
|
1534
|
+
qs.parse('a[]=1,2,3', { comma: true, arrayLimit: 0, throwOnLimitExceeded: true });
|
|
1535
|
+
},
|
|
1536
|
+
new RangeError('Array limit exceeded. Only 0 elements allowed in an array.'),
|
|
1537
|
+
'a single bracketed element still exceeds arrayLimit 0'
|
|
1538
|
+
);
|
|
1539
|
+
sst.end();
|
|
1540
|
+
});
|
|
1541
|
+
|
|
1312
1542
|
st.end();
|
|
1313
1543
|
});
|
|
1314
1544
|
|
|
@@ -65,6 +65,7 @@ test('merge()', function (t) {
|
|
|
65
65
|
observed[0] = observed[0]; // eslint-disable-line no-self-assign
|
|
66
66
|
st.equal(setCount, 1);
|
|
67
67
|
st.equal(getCount, 2);
|
|
68
|
+
|
|
68
69
|
st.end();
|
|
69
70
|
}
|
|
70
71
|
);
|
|
@@ -78,6 +79,7 @@ test('merge()', function (t) {
|
|
|
78
79
|
s2t.ok(utils.isOverflow(overflow), 'overflow object is marked');
|
|
79
80
|
var merged = utils.merge(overflow, 'd');
|
|
80
81
|
s2t.deepEqual(merged, { 0: 'a', 1: 'b', 2: 'c', 3: 'd' }, 'adds primitive at next numeric index');
|
|
82
|
+
|
|
81
83
|
s2t.end();
|
|
82
84
|
});
|
|
83
85
|
|
|
@@ -93,6 +95,7 @@ test('merge()', function (t) {
|
|
|
93
95
|
var obj = { foo: 'bar' };
|
|
94
96
|
var merged = utils.merge(obj, 'baz');
|
|
95
97
|
s2t.deepEqual(merged, { foo: 'bar', baz: true }, 'adds primitive as key with value true');
|
|
98
|
+
|
|
96
99
|
s2t.end();
|
|
97
100
|
});
|
|
98
101
|
|
|
@@ -110,6 +113,7 @@ test('merge()', function (t) {
|
|
|
110
113
|
var merged = utils.merge('c', overflow);
|
|
111
114
|
s2t.ok(utils.isOverflow(merged), 'result is also marked as overflow');
|
|
112
115
|
s2t.deepEqual(merged, { 0: 'c', 1: 'a', 2: 'b' }, 'creates object with primitive at 0, source values shifted');
|
|
116
|
+
|
|
113
117
|
s2t.end();
|
|
114
118
|
});
|
|
115
119
|
|
|
@@ -119,6 +123,7 @@ test('merge()', function (t) {
|
|
|
119
123
|
var merged = utils.merge('c', overflow, { plainObjects: true });
|
|
120
124
|
s2t.ok(utils.isOverflow(merged), 'result is also marked as overflow');
|
|
121
125
|
s2t.deepEqual(merged, { __proto__: null, 0: 'c', 1: 'a', 2: 'b' }, 'creates null-proto object with primitive at 0');
|
|
126
|
+
|
|
122
127
|
s2t.end();
|
|
123
128
|
});
|
|
124
129
|
|
|
@@ -128,6 +133,7 @@ test('merge()', function (t) {
|
|
|
128
133
|
s2t.ok(utils.isOverflow(overflow), 'overflow object is marked');
|
|
129
134
|
var merged = utils.merge('a', overflow);
|
|
130
135
|
s2t.deepEqual(merged, { 0: 'a', 1: 'b', 2: 'c', 3: 'd' }, 'shifts all source indices by 1');
|
|
136
|
+
|
|
131
137
|
s2t.end();
|
|
132
138
|
});
|
|
133
139
|
|
|
@@ -135,6 +141,7 @@ test('merge()', function (t) {
|
|
|
135
141
|
var obj = { foo: 'bar' };
|
|
136
142
|
var merged = utils.merge('a', obj);
|
|
137
143
|
s2t.deepEqual(merged, ['a', { foo: 'bar' }], 'creates array with primitive and object');
|
|
144
|
+
|
|
138
145
|
s2t.end();
|
|
139
146
|
});
|
|
140
147
|
|
|
@@ -143,6 +150,7 @@ test('merge()', function (t) {
|
|
|
143
150
|
var merged = utils.merge(arr, 'd', { arrayLimit: 1 });
|
|
144
151
|
s2t.ok(utils.isOverflow(merged), 'result is marked as overflow');
|
|
145
152
|
s2t.deepEqual(merged, { 0: 'a', 1: 'b', 2: 'c', 3: 'd' }, 'converts to overflow object with primitive appended');
|
|
153
|
+
|
|
146
154
|
s2t.end();
|
|
147
155
|
});
|
|
148
156
|
|
|
@@ -150,6 +158,78 @@ test('merge()', function (t) {
|
|
|
150
158
|
var merged = utils.merge('a', ['b', 'c'], { arrayLimit: 1 });
|
|
151
159
|
s2t.ok(utils.isOverflow(merged), 'result is marked as overflow');
|
|
152
160
|
s2t.deepEqual(merged, { 0: 'a', 1: 'b', 2: 'c' }, 'converts to overflow object');
|
|
161
|
+
|
|
162
|
+
s2t.end();
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
st.test('merges primitive into array at the arrayLimit boundary, consistently with combine', function (s2t) {
|
|
166
|
+
var merged = utils.merge(['a'], 'b', { arrayLimit: 1 });
|
|
167
|
+
s2t.ok(utils.isOverflow(merged), 'result is marked as overflow at the boundary');
|
|
168
|
+
s2t.deepEqual(merged, { 0: 'a', 1: 'b' }, 'converts to overflow object instead of a length-2 array');
|
|
169
|
+
|
|
170
|
+
s2t.end();
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
st.test('merges two arrays that exceed arrayLimit into an overflow object', function (s2t) {
|
|
174
|
+
var merged = utils.merge(['a'], ['b'], { arrayLimit: 1 });
|
|
175
|
+
s2t.ok(utils.isOverflow(merged), 'result is marked as overflow');
|
|
176
|
+
s2t.deepEqual(merged, { 0: 'a', 1: 'b' }, 'array-into-array merge enforces arrayLimit like combine');
|
|
177
|
+
|
|
178
|
+
s2t.end();
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
st.test('throws at the arrayLimit boundary when merging a primitive into an array with throwOnLimitExceeded', function (s2t) {
|
|
182
|
+
s2t['throws'](
|
|
183
|
+
function () { utils.merge(['a'], 'b', { arrayLimit: 1, throwOnLimitExceeded: true }); },
|
|
184
|
+
new RangeError('Array limit exceeded. Only 1 element allowed in an array.'),
|
|
185
|
+
'throws when the resulting length would exceed arrayLimit'
|
|
186
|
+
);
|
|
187
|
+
|
|
188
|
+
s2t.end();
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
st.test('throws when merging two arrays past arrayLimit with throwOnLimitExceeded', function (s2t) {
|
|
192
|
+
s2t['throws'](
|
|
193
|
+
function () { utils.merge(['a'], ['b'], { arrayLimit: 1, throwOnLimitExceeded: true }); },
|
|
194
|
+
new RangeError('Array limit exceeded. Only 1 element allowed in an array.'),
|
|
195
|
+
'array-into-array merge throws rather than silently exceeding arrayLimit'
|
|
196
|
+
);
|
|
197
|
+
s2t['throws'](
|
|
198
|
+
function () { utils.merge(['a', 'b', 'c'], ['d', 'e', 'f'], { arrayLimit: 2, throwOnLimitExceeded: true }); },
|
|
199
|
+
new RangeError('Array limit exceeded. Only 2 elements allowed in an array.'),
|
|
200
|
+
'uses the plural message when arrayLimit is not 1'
|
|
201
|
+
);
|
|
202
|
+
|
|
203
|
+
s2t.end();
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
st.test('throws instead of merging primitive into over-limit array when throwOnLimitExceeded is set', function (s2t) {
|
|
207
|
+
s2t['throws'](
|
|
208
|
+
function () { utils.merge(['a', 'b', 'c'], 'd', { arrayLimit: 1, throwOnLimitExceeded: true }); },
|
|
209
|
+
new RangeError('Array limit exceeded. Only 1 element allowed in an array.'),
|
|
210
|
+
'throws rather than converting to an overflow object'
|
|
211
|
+
);
|
|
212
|
+
s2t['throws'](
|
|
213
|
+
function () { utils.merge(['a', 'b', 'c'], 'd', { arrayLimit: 2, throwOnLimitExceeded: true }); },
|
|
214
|
+
new RangeError('Array limit exceeded. Only 2 elements allowed in an array.'),
|
|
215
|
+
'uses the plural message when arrayLimit is not 1'
|
|
216
|
+
);
|
|
217
|
+
|
|
218
|
+
s2t.end();
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
st.test('throws instead of merging array into primitive when throwOnLimitExceeded is set', function (s2t) {
|
|
222
|
+
s2t['throws'](
|
|
223
|
+
function () { utils.merge('a', ['b', 'c'], { arrayLimit: 1, throwOnLimitExceeded: true }); },
|
|
224
|
+
new RangeError('Array limit exceeded. Only 1 element allowed in an array.'),
|
|
225
|
+
'throws rather than converting to an overflow object'
|
|
226
|
+
);
|
|
227
|
+
s2t['throws'](
|
|
228
|
+
function () { utils.merge('a', ['b', 'c', 'd'], { arrayLimit: 2, throwOnLimitExceeded: true }); },
|
|
229
|
+
new RangeError('Array limit exceeded. Only 2 elements allowed in an array.'),
|
|
230
|
+
'uses the plural message when arrayLimit is not 1'
|
|
231
|
+
);
|
|
232
|
+
|
|
153
233
|
s2t.end();
|
|
154
234
|
});
|
|
155
235
|
|
|
@@ -274,6 +354,47 @@ test('combine()', function (t) {
|
|
|
274
354
|
st.end();
|
|
275
355
|
});
|
|
276
356
|
|
|
357
|
+
t.test('with throwOnLimitExceeded', function (st) {
|
|
358
|
+
st.test('throws when concatenation exceeds the limit', function (s2t) {
|
|
359
|
+
s2t['throws'](
|
|
360
|
+
function () { utils.combine(['a', 'b', 'c'], 'd', 3, false, true); },
|
|
361
|
+
new RangeError('Array limit exceeded. Only 3 elements allowed in an array.'),
|
|
362
|
+
'throws instead of converting to an overflow object'
|
|
363
|
+
);
|
|
364
|
+
s2t['throws'](
|
|
365
|
+
function () { utils.combine([], 'a', 0, false, true); },
|
|
366
|
+
new RangeError('Array limit exceeded. Only 0 elements allowed in an array.'),
|
|
367
|
+
'throws with the correct count at arrayLimit 0'
|
|
368
|
+
);
|
|
369
|
+
s2t.end();
|
|
370
|
+
});
|
|
371
|
+
|
|
372
|
+
st.test('throws when adding to an existing overflow object', function (s2t) {
|
|
373
|
+
var overflow = utils.combine(['a', 'b'], 'c', 0, false);
|
|
374
|
+
s2t.ok(utils.isOverflow(overflow), 'initial object is marked as overflow');
|
|
375
|
+
|
|
376
|
+
s2t['throws'](
|
|
377
|
+
function () { utils.combine(overflow, 'd', 0, false, true); },
|
|
378
|
+
new RangeError('Array limit exceeded. Only 0 elements allowed in an array.'),
|
|
379
|
+
'throws rather than appending to the overflow object'
|
|
380
|
+
);
|
|
381
|
+
s2t['throws'](
|
|
382
|
+
function () { utils.combine(overflow, 'd', 1, false, true); },
|
|
383
|
+
new RangeError('Array limit exceeded. Only 1 element allowed in an array.'),
|
|
384
|
+
'uses the singular message at arrayLimit 1'
|
|
385
|
+
);
|
|
386
|
+
s2t.end();
|
|
387
|
+
});
|
|
388
|
+
|
|
389
|
+
st.test('does not throw when within the limit', function (s2t) {
|
|
390
|
+
var combined = utils.combine(['a'], 'b', 5, false, true);
|
|
391
|
+
s2t.deepEqual(combined, ['a', 'b'], 'returns the array unchanged when under the limit');
|
|
392
|
+
s2t.end();
|
|
393
|
+
});
|
|
394
|
+
|
|
395
|
+
st.end();
|
|
396
|
+
});
|
|
397
|
+
|
|
277
398
|
t.test('with existing overflow object', function (st) {
|
|
278
399
|
st.test('adds to existing overflow object at next index', function (s2t) {
|
|
279
400
|
// Create overflow object first via combine: 3 elements (indices 0-2) with limit 0
|
|
@@ -372,6 +493,79 @@ test('encode', function (t) {
|
|
|
372
493
|
'encodes a long string'
|
|
373
494
|
);
|
|
374
495
|
|
|
496
|
+
var boundary = '';
|
|
497
|
+
var expected = '';
|
|
498
|
+
for (var j = 0; j < 1023; j++) {
|
|
499
|
+
boundary += 'a';
|
|
500
|
+
expected += 'a';
|
|
501
|
+
}
|
|
502
|
+
boundary += '😀';
|
|
503
|
+
expected += '%F0%9F%98%80';
|
|
504
|
+
|
|
505
|
+
t.equal(
|
|
506
|
+
utils.encode(boundary),
|
|
507
|
+
expected,
|
|
508
|
+
'encodes a surrogate pair split across long-string chunks'
|
|
509
|
+
);
|
|
510
|
+
|
|
511
|
+
var laterBoundary = '';
|
|
512
|
+
var laterExpected = '';
|
|
513
|
+
for (var k = 0; k < 2047; k++) {
|
|
514
|
+
laterBoundary += 'a';
|
|
515
|
+
laterExpected += 'a';
|
|
516
|
+
}
|
|
517
|
+
laterBoundary += '😀';
|
|
518
|
+
laterExpected += '%F0%9F%98%80';
|
|
519
|
+
|
|
520
|
+
t.equal(
|
|
521
|
+
utils.encode(laterBoundary),
|
|
522
|
+
laterExpected,
|
|
523
|
+
'encodes a surrogate pair split across a later chunk boundary'
|
|
524
|
+
);
|
|
525
|
+
|
|
526
|
+
var twoPairs = '';
|
|
527
|
+
for (k = 0; k < 1023; k++) {
|
|
528
|
+
twoPairs += 'a';
|
|
529
|
+
}
|
|
530
|
+
twoPairs += '😀';
|
|
531
|
+
for (k = 0; k < 1022; k++) {
|
|
532
|
+
twoPairs += 'b';
|
|
533
|
+
}
|
|
534
|
+
twoPairs += '😀';
|
|
535
|
+
|
|
536
|
+
t.equal(
|
|
537
|
+
(utils.encode(twoPairs).match(/%F0%9F%98%80/g) || []).length,
|
|
538
|
+
2,
|
|
539
|
+
'encodes two surrogate pairs each split across a chunk boundary'
|
|
540
|
+
);
|
|
541
|
+
|
|
542
|
+
var roundTrip = '';
|
|
543
|
+
for (k = 0; k < 1023; k++) {
|
|
544
|
+
roundTrip += 'a';
|
|
545
|
+
}
|
|
546
|
+
roundTrip += '😀';
|
|
547
|
+
|
|
548
|
+
t.equal(
|
|
549
|
+
decodeURIComponent(utils.encode(roundTrip)),
|
|
550
|
+
roundTrip,
|
|
551
|
+
'a boundary-split surrogate pair round-trips through decodeURIComponent'
|
|
552
|
+
);
|
|
553
|
+
|
|
554
|
+
var loneBoundary = '';
|
|
555
|
+
var loneExpected = '';
|
|
556
|
+
for (k = 0; k < 1023; k++) {
|
|
557
|
+
loneBoundary += 'a';
|
|
558
|
+
loneExpected += 'a';
|
|
559
|
+
}
|
|
560
|
+
loneBoundary += '\uD83DX';
|
|
561
|
+
loneExpected += '%F0%9F%91%98';
|
|
562
|
+
|
|
563
|
+
t.equal(
|
|
564
|
+
utils.encode(loneBoundary),
|
|
565
|
+
loneExpected,
|
|
566
|
+
'a lone high surrogate at a chunk boundary encodes the same as mid-chunk'
|
|
567
|
+
);
|
|
568
|
+
|
|
375
569
|
t.equal(
|
|
376
570
|
utils.encode('\x28\x29'),
|
|
377
571
|
'%28%29',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zuplo/cli",
|
|
3
|
-
"version": "6.71.
|
|
3
|
+
"version": "6.71.17",
|
|
4
4
|
"repository": "https://github.com/zuplo/zuplo",
|
|
5
5
|
"author": "Zuplo, Inc.",
|
|
6
6
|
"type": "module",
|
|
@@ -27,10 +27,10 @@
|
|
|
27
27
|
"@opentelemetry/api": "1.9.0",
|
|
28
28
|
"@opentelemetry/api-logs": "0.201.1",
|
|
29
29
|
"@swc/core": "1.10.18",
|
|
30
|
-
"@zuplo/core": "6.71.
|
|
30
|
+
"@zuplo/core": "6.71.17",
|
|
31
31
|
"@zuplo/editor": "1.0.20821740935",
|
|
32
|
-
"@zuplo/openapi-tools": "6.71.
|
|
33
|
-
"@zuplo/runtime": "6.71.
|
|
32
|
+
"@zuplo/openapi-tools": "6.71.17",
|
|
33
|
+
"@zuplo/runtime": "6.71.17",
|
|
34
34
|
"chalk": "5.4.1",
|
|
35
35
|
"chokidar": "3.5.3",
|
|
36
36
|
"cookie": "1.0.2",
|
|
@@ -61,8 +61,8 @@
|
|
|
61
61
|
"workerd": "1.20241230.0",
|
|
62
62
|
"yargs": "17.7.2",
|
|
63
63
|
"zod": "3.25.76",
|
|
64
|
-
"@zuplo/graphql": "6.71.
|
|
65
|
-
"@zuplo/otel": "6.71.
|
|
64
|
+
"@zuplo/graphql": "6.71.17",
|
|
65
|
+
"@zuplo/otel": "6.71.17"
|
|
66
66
|
},
|
|
67
67
|
"bundleDependencies": [
|
|
68
68
|
"@inquirer/prompts",
|