meteor-node-stubs 1.2.9 → 1.2.11
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/call-bind/CHANGELOG.md +16 -0
- package/node_modules/call-bind/index.js +2 -11
- package/node_modules/call-bind/package.json +11 -6
- package/node_modules/define-data-property/CHANGELOG.md +29 -0
- package/node_modules/define-data-property/index.d.ts +12 -3
- package/node_modules/define-data-property/index.js +4 -16
- package/node_modules/define-data-property/package.json +26 -33
- package/node_modules/define-data-property/test/index.js +10 -10
- package/node_modules/elliptic/lib/elliptic/ec/signature.js +10 -0
- package/node_modules/elliptic/lib/elliptic/eddsa/index.js +3 -0
- package/node_modules/elliptic/lib/elliptic/eddsa/signature.js +1 -0
- package/node_modules/elliptic/package.json +1 -1
- package/node_modules/es-define-property/.eslintrc +13 -0
- package/node_modules/es-define-property/.github/FUNDING.yml +12 -0
- package/node_modules/es-define-property/.nycrc +9 -0
- package/node_modules/es-define-property/CHANGELOG.md +15 -0
- package/node_modules/es-define-property/LICENSE +21 -0
- package/node_modules/es-define-property/README.md +49 -0
- package/node_modules/es-define-property/index.d.ts +3 -0
- package/node_modules/es-define-property/index.js +16 -0
- package/node_modules/es-define-property/package.json +81 -0
- package/node_modules/es-define-property/test/index.js +55 -0
- package/node_modules/es-define-property/tsconfig.json +50 -0
- package/node_modules/es-errors/.eslintrc +5 -0
- package/node_modules/es-errors/.github/FUNDING.yml +12 -0
- package/node_modules/es-errors/CHANGELOG.md +40 -0
- package/node_modules/es-errors/LICENSE +21 -0
- package/node_modules/es-errors/README.md +55 -0
- package/node_modules/es-errors/eval.d.ts +3 -0
- package/node_modules/es-errors/eval.js +4 -0
- package/node_modules/es-errors/index.d.ts +3 -0
- package/node_modules/es-errors/index.js +4 -0
- package/node_modules/es-errors/package.json +80 -0
- package/node_modules/es-errors/range.d.ts +3 -0
- package/node_modules/es-errors/range.js +4 -0
- package/node_modules/es-errors/ref.d.ts +3 -0
- package/node_modules/es-errors/ref.js +4 -0
- package/node_modules/es-errors/syntax.d.ts +3 -0
- package/node_modules/es-errors/syntax.js +4 -0
- package/node_modules/es-errors/test/index.js +19 -0
- package/node_modules/es-errors/tsconfig.json +49 -0
- package/node_modules/es-errors/type.d.ts +3 -0
- package/node_modules/es-errors/type.js +4 -0
- package/node_modules/es-errors/uri.d.ts +3 -0
- package/node_modules/es-errors/uri.js +4 -0
- package/node_modules/get-intrinsic/CHANGELOG.md +18 -0
- package/node_modules/get-intrinsic/index.js +15 -7
- package/node_modules/get-intrinsic/package.json +12 -12
- package/node_modules/has-property-descriptors/CHANGELOG.md +8 -0
- package/node_modules/has-property-descriptors/index.js +3 -14
- package/node_modules/has-property-descriptors/package.json +5 -5
- package/node_modules/object-inspect/CHANGELOG.md +15 -0
- package/node_modules/object-inspect/index.js +4 -1
- package/node_modules/object-inspect/package.json +14 -9
- package/node_modules/object-inspect/readme.markdown +9 -11
- package/node_modules/qs/.editorconfig +3 -0
- package/node_modules/qs/.eslintrc +1 -1
- package/node_modules/qs/CHANGELOG.md +41 -0
- package/node_modules/qs/README.md +97 -51
- package/node_modules/qs/dist/qs.js +56 -2053
- package/node_modules/qs/lib/parse.js +44 -12
- package/node_modules/qs/lib/stringify.js +49 -18
- package/node_modules/qs/lib/utils.js +47 -34
- package/node_modules/qs/package.json +26 -15
- package/node_modules/qs/test/empty-keys-cases.js +261 -31
- package/node_modules/qs/test/parse.js +302 -30
- package/node_modules/qs/test/stringify.js +374 -48
- package/node_modules/set-function-length/CHANGELOG.md +29 -0
- package/node_modules/set-function-length/env.d.ts +9 -0
- package/node_modules/set-function-length/env.js +10 -4
- package/node_modules/set-function-length/index.d.ts +7 -0
- package/node_modules/set-function-length/index.js +4 -3
- package/node_modules/set-function-length/package.json +29 -11
- package/node_modules/set-function-length/tsconfig.json +9 -0
- package/node_modules/side-channel/.editorconfig +9 -0
- package/node_modules/side-channel/.eslintrc +1 -1
- package/node_modules/side-channel/CHANGELOG.md +30 -0
- package/node_modules/side-channel/index.d.ts +27 -0
- package/node_modules/side-channel/index.js +25 -20
- package/node_modules/side-channel/package.json +36 -19
- package/node_modules/side-channel/test/index.js +6 -1
- package/node_modules/side-channel/tsconfig.json +50 -0
- package/node_modules/url/package.json +9 -6
- package/node_modules/url/url.js +1 -1
- package/package.json +4 -4
- package/scripts/build-deps.js +12 -12
- package/node_modules/define-data-property/index.d.ts.map +0 -1
- package/node_modules/side-channel/.eslintignore +0 -1
|
@@ -6,6 +6,8 @@ var iconv = require('iconv-lite');
|
|
|
6
6
|
var mockProperty = require('mock-property');
|
|
7
7
|
var hasOverrideMistake = require('has-override-mistake')();
|
|
8
8
|
var SaferBuffer = require('safer-buffer').Buffer;
|
|
9
|
+
var v = require('es-value-fixtures');
|
|
10
|
+
var inspect = require('object-inspect');
|
|
9
11
|
var emptyTestCases = require('./empty-keys-cases').emptyTestCases;
|
|
10
12
|
|
|
11
13
|
var qs = require('../');
|
|
@@ -37,41 +39,156 @@ test('parse()', function (t) {
|
|
|
37
39
|
st.end();
|
|
38
40
|
});
|
|
39
41
|
|
|
40
|
-
t.test('
|
|
41
|
-
st.deepEqual(qs.parse('a[]=b&a[]=c'
|
|
42
|
-
st.deepEqual(qs.parse('a[0]=b&a[1]=c'
|
|
43
|
-
st.deepEqual(qs.parse('a=b,c'
|
|
44
|
-
st.deepEqual(qs.parse('a=b&a=c'
|
|
42
|
+
t.test('comma: false', function (st) {
|
|
43
|
+
st.deepEqual(qs.parse('a[]=b&a[]=c'), { a: ['b', 'c'] });
|
|
44
|
+
st.deepEqual(qs.parse('a[0]=b&a[1]=c'), { a: ['b', 'c'] });
|
|
45
|
+
st.deepEqual(qs.parse('a=b,c'), { a: 'b,c' });
|
|
46
|
+
st.deepEqual(qs.parse('a=b&a=c'), { a: ['b', 'c'] });
|
|
45
47
|
st.end();
|
|
46
48
|
});
|
|
47
49
|
|
|
48
|
-
t.test('
|
|
49
|
-
st.deepEqual(qs.parse('a[]=b&a[]=c', {
|
|
50
|
-
st.deepEqual(qs.parse('a[0]=b&a[1]=c', {
|
|
51
|
-
st.deepEqual(qs.parse('a=b,c', {
|
|
52
|
-
st.deepEqual(qs.parse('a=b&a=c', {
|
|
50
|
+
t.test('comma: true', function (st) {
|
|
51
|
+
st.deepEqual(qs.parse('a[]=b&a[]=c', { comma: true }), { a: ['b', 'c'] });
|
|
52
|
+
st.deepEqual(qs.parse('a[0]=b&a[1]=c', { comma: true }), { a: ['b', 'c'] });
|
|
53
|
+
st.deepEqual(qs.parse('a=b,c', { comma: true }), { a: ['b', 'c'] });
|
|
54
|
+
st.deepEqual(qs.parse('a=b&a=c', { comma: true }), { a: ['b', 'c'] });
|
|
53
55
|
st.end();
|
|
54
56
|
});
|
|
55
57
|
|
|
56
|
-
t.test('
|
|
57
|
-
st.deepEqual(qs.parse('a
|
|
58
|
-
st.deepEqual(qs.parse('a
|
|
59
|
-
|
|
60
|
-
st.deepEqual(qs.parse('a=b&a=c', { arrayFormat: 'comma' }), { a: ['b', 'c'] });
|
|
58
|
+
t.test('allows enabling dot notation', function (st) {
|
|
59
|
+
st.deepEqual(qs.parse('a.b=c'), { 'a.b': 'c' });
|
|
60
|
+
st.deepEqual(qs.parse('a.b=c', { allowDots: true }), { a: { b: 'c' } });
|
|
61
|
+
|
|
61
62
|
st.end();
|
|
62
63
|
});
|
|
63
64
|
|
|
64
|
-
t.test('
|
|
65
|
-
st.deepEqual(
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
65
|
+
t.test('decode dot keys correctly', function (st) {
|
|
66
|
+
st.deepEqual(
|
|
67
|
+
qs.parse('name%252Eobj.first=John&name%252Eobj.last=Doe', { allowDots: false, decodeDotInKeys: false }),
|
|
68
|
+
{ 'name%2Eobj.first': 'John', 'name%2Eobj.last': 'Doe' },
|
|
69
|
+
'with allowDots false and decodeDotInKeys false'
|
|
70
|
+
);
|
|
71
|
+
st.deepEqual(
|
|
72
|
+
qs.parse('name.obj.first=John&name.obj.last=Doe', { allowDots: true, decodeDotInKeys: false }),
|
|
73
|
+
{ name: { obj: { first: 'John', last: 'Doe' } } },
|
|
74
|
+
'with allowDots false and decodeDotInKeys false'
|
|
75
|
+
);
|
|
76
|
+
st.deepEqual(
|
|
77
|
+
qs.parse('name%252Eobj.first=John&name%252Eobj.last=Doe', { allowDots: true, decodeDotInKeys: false }),
|
|
78
|
+
{ 'name%2Eobj': { first: 'John', last: 'Doe' } },
|
|
79
|
+
'with allowDots true and decodeDotInKeys false'
|
|
80
|
+
);
|
|
81
|
+
st.deepEqual(
|
|
82
|
+
qs.parse('name%252Eobj.first=John&name%252Eobj.last=Doe', { allowDots: true, decodeDotInKeys: true }),
|
|
83
|
+
{ 'name.obj': { first: 'John', last: 'Doe' } },
|
|
84
|
+
'with allowDots true and decodeDotInKeys true'
|
|
85
|
+
);
|
|
86
|
+
|
|
87
|
+
st.deepEqual(
|
|
88
|
+
qs.parse(
|
|
89
|
+
'name%252Eobj%252Esubobject.first%252Egodly%252Ename=John&name%252Eobj%252Esubobject.last=Doe',
|
|
90
|
+
{ allowDots: false, decodeDotInKeys: false }
|
|
91
|
+
),
|
|
92
|
+
{ 'name%2Eobj%2Esubobject.first%2Egodly%2Ename': 'John', 'name%2Eobj%2Esubobject.last': 'Doe' },
|
|
93
|
+
'with allowDots false and decodeDotInKeys false'
|
|
94
|
+
);
|
|
95
|
+
st.deepEqual(
|
|
96
|
+
qs.parse(
|
|
97
|
+
'name.obj.subobject.first.godly.name=John&name.obj.subobject.last=Doe',
|
|
98
|
+
{ allowDots: true, decodeDotInKeys: false }
|
|
99
|
+
),
|
|
100
|
+
{ name: { obj: { subobject: { first: { godly: { name: 'John' } }, last: 'Doe' } } } },
|
|
101
|
+
'with allowDots true and decodeDotInKeys false'
|
|
102
|
+
);
|
|
103
|
+
st.deepEqual(
|
|
104
|
+
qs.parse(
|
|
105
|
+
'name%252Eobj%252Esubobject.first%252Egodly%252Ename=John&name%252Eobj%252Esubobject.last=Doe',
|
|
106
|
+
{ allowDots: true, decodeDotInKeys: true }
|
|
107
|
+
),
|
|
108
|
+
{ 'name.obj.subobject': { 'first.godly.name': 'John', last: 'Doe' } },
|
|
109
|
+
'with allowDots true and decodeDotInKeys true'
|
|
110
|
+
);
|
|
111
|
+
st.deepEqual(
|
|
112
|
+
qs.parse('name%252Eobj.first=John&name%252Eobj.last=Doe'),
|
|
113
|
+
{ 'name%2Eobj.first': 'John', 'name%2Eobj.last': 'Doe' },
|
|
114
|
+
'with allowDots and decodeDotInKeys undefined'
|
|
115
|
+
);
|
|
116
|
+
|
|
69
117
|
st.end();
|
|
70
118
|
});
|
|
71
119
|
|
|
72
|
-
t.test('
|
|
73
|
-
st.deepEqual(
|
|
74
|
-
|
|
120
|
+
t.test('should decode dot in key of object, and allow enabling dot notation when decodeDotInKeys is set to true and allowDots is undefined', function (st) {
|
|
121
|
+
st.deepEqual(
|
|
122
|
+
qs.parse(
|
|
123
|
+
'name%252Eobj%252Esubobject.first%252Egodly%252Ename=John&name%252Eobj%252Esubobject.last=Doe',
|
|
124
|
+
{ decodeDotInKeys: true }
|
|
125
|
+
),
|
|
126
|
+
{ 'name.obj.subobject': { 'first.godly.name': 'John', last: 'Doe' } },
|
|
127
|
+
'with allowDots undefined and decodeDotInKeys true'
|
|
128
|
+
);
|
|
129
|
+
|
|
130
|
+
st.end();
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
t.test('should throw when decodeDotInKeys is not of type boolean', function (st) {
|
|
134
|
+
st['throws'](
|
|
135
|
+
function () { qs.parse('foo[]&bar=baz', { decodeDotInKeys: 'foobar' }); },
|
|
136
|
+
TypeError
|
|
137
|
+
);
|
|
138
|
+
|
|
139
|
+
st['throws'](
|
|
140
|
+
function () { qs.parse('foo[]&bar=baz', { decodeDotInKeys: 0 }); },
|
|
141
|
+
TypeError
|
|
142
|
+
);
|
|
143
|
+
st['throws'](
|
|
144
|
+
function () { qs.parse('foo[]&bar=baz', { decodeDotInKeys: NaN }); },
|
|
145
|
+
TypeError
|
|
146
|
+
);
|
|
147
|
+
|
|
148
|
+
st['throws'](
|
|
149
|
+
function () { qs.parse('foo[]&bar=baz', { decodeDotInKeys: null }); },
|
|
150
|
+
TypeError
|
|
151
|
+
);
|
|
152
|
+
|
|
153
|
+
st.end();
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
t.test('allows empty arrays in obj values', function (st) {
|
|
157
|
+
st.deepEqual(qs.parse('foo[]&bar=baz', { allowEmptyArrays: true }), { foo: [], bar: 'baz' });
|
|
158
|
+
st.deepEqual(qs.parse('foo[]&bar=baz', { allowEmptyArrays: false }), { foo: [''], bar: 'baz' });
|
|
159
|
+
|
|
160
|
+
st.end();
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
t.test('should throw when allowEmptyArrays is not of type boolean', function (st) {
|
|
164
|
+
st['throws'](
|
|
165
|
+
function () { qs.parse('foo[]&bar=baz', { allowEmptyArrays: 'foobar' }); },
|
|
166
|
+
TypeError
|
|
167
|
+
);
|
|
168
|
+
|
|
169
|
+
st['throws'](
|
|
170
|
+
function () { qs.parse('foo[]&bar=baz', { allowEmptyArrays: 0 }); },
|
|
171
|
+
TypeError
|
|
172
|
+
);
|
|
173
|
+
st['throws'](
|
|
174
|
+
function () { qs.parse('foo[]&bar=baz', { allowEmptyArrays: NaN }); },
|
|
175
|
+
TypeError
|
|
176
|
+
);
|
|
177
|
+
|
|
178
|
+
st['throws'](
|
|
179
|
+
function () { qs.parse('foo[]&bar=baz', { allowEmptyArrays: null }); },
|
|
180
|
+
TypeError
|
|
181
|
+
);
|
|
182
|
+
|
|
183
|
+
st.end();
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
t.test('allowEmptyArrays + strictNullHandling', function (st) {
|
|
187
|
+
st.deepEqual(
|
|
188
|
+
qs.parse('testEmptyArray[]', { strictNullHandling: true, allowEmptyArrays: true }),
|
|
189
|
+
{ testEmptyArray: [] }
|
|
190
|
+
);
|
|
191
|
+
|
|
75
192
|
st.end();
|
|
76
193
|
});
|
|
77
194
|
|
|
@@ -327,14 +444,14 @@ test('parse()', function (t) {
|
|
|
327
444
|
});
|
|
328
445
|
|
|
329
446
|
t.test('should not throw when a native prototype has an enumerable property', function (st) {
|
|
330
|
-
Object.prototype
|
|
331
|
-
Array.prototype
|
|
447
|
+
st.intercept(Object.prototype, 'crash', { value: '' });
|
|
448
|
+
st.intercept(Array.prototype, 'crash', { value: '' });
|
|
449
|
+
|
|
332
450
|
st.doesNotThrow(qs.parse.bind(null, 'a=b'));
|
|
333
451
|
st.deepEqual(qs.parse('a=b'), { a: 'b' });
|
|
334
452
|
st.doesNotThrow(qs.parse.bind(null, 'a[][b]=c'));
|
|
335
453
|
st.deepEqual(qs.parse('a[][b]=c'), { a: [{ b: 'c' }] });
|
|
336
|
-
|
|
337
|
-
delete Array.prototype.crash;
|
|
454
|
+
|
|
338
455
|
st.end();
|
|
339
456
|
});
|
|
340
457
|
|
|
@@ -365,8 +482,14 @@ test('parse()', function (t) {
|
|
|
365
482
|
|
|
366
483
|
t.test('allows overriding array limit', function (st) {
|
|
367
484
|
st.deepEqual(qs.parse('a[0]=b', { arrayLimit: -1 }), { a: { 0: 'b' } });
|
|
485
|
+
st.deepEqual(qs.parse('a[0]=b', { arrayLimit: 0 }), { a: ['b'] });
|
|
486
|
+
|
|
368
487
|
st.deepEqual(qs.parse('a[-1]=b', { arrayLimit: -1 }), { a: { '-1': 'b' } });
|
|
488
|
+
st.deepEqual(qs.parse('a[-1]=b', { arrayLimit: 0 }), { a: { '-1': 'b' } });
|
|
489
|
+
|
|
490
|
+
st.deepEqual(qs.parse('a[0]=b&a[1]=c', { arrayLimit: -1 }), { a: { 0: 'b', 1: 'c' } });
|
|
369
491
|
st.deepEqual(qs.parse('a[0]=b&a[1]=c', { arrayLimit: 0 }), { a: { 0: 'b', 1: 'c' } });
|
|
492
|
+
|
|
370
493
|
st.end();
|
|
371
494
|
});
|
|
372
495
|
|
|
@@ -457,6 +580,15 @@ test('parse()', function (t) {
|
|
|
457
580
|
st.end();
|
|
458
581
|
});
|
|
459
582
|
|
|
583
|
+
t.test('parses url-encoded brackets holds array of arrays when having two parts of strings with comma as array divider', function (st) {
|
|
584
|
+
st.deepEqual(qs.parse('foo%5B%5D=1,2,3&foo%5B%5D=4,5,6', { comma: true }), { foo: [['1', '2', '3'], ['4', '5', '6']] });
|
|
585
|
+
st.deepEqual(qs.parse('foo%5B%5D=1,2,3&foo%5B%5D=', { comma: true }), { foo: [['1', '2', '3'], ''] });
|
|
586
|
+
st.deepEqual(qs.parse('foo%5B%5D=1,2,3&foo%5B%5D=,', { comma: true }), { foo: [['1', '2', '3'], ['', '']] });
|
|
587
|
+
st.deepEqual(qs.parse('foo%5B%5D=1,2,3&foo%5B%5D=a', { comma: true }), { foo: [['1', '2', '3'], 'a'] });
|
|
588
|
+
|
|
589
|
+
st.end();
|
|
590
|
+
});
|
|
591
|
+
|
|
460
592
|
t.test('parses comma delimited array while having percent-encoded comma treated as normal text', function (st) {
|
|
461
593
|
st.deepEqual(qs.parse('foo=a%2Cb', { comma: true }), { foo: 'a,b' });
|
|
462
594
|
st.deepEqual(qs.parse('foo=a%2C%20b,d', { comma: true }), { foo: ['a, b', 'd'] });
|
|
@@ -504,10 +636,12 @@ test('parse()', function (t) {
|
|
|
504
636
|
});
|
|
505
637
|
|
|
506
638
|
t.test('does not blow up when Buffer global is missing', function (st) {
|
|
507
|
-
var
|
|
508
|
-
|
|
639
|
+
var restore = mockProperty(global, 'Buffer', { 'delete': true });
|
|
640
|
+
|
|
509
641
|
var result = qs.parse('a=b&c=d');
|
|
510
|
-
|
|
642
|
+
|
|
643
|
+
restore();
|
|
644
|
+
|
|
511
645
|
st.deepEqual(result, { a: 'b', c: 'd' });
|
|
512
646
|
st.end();
|
|
513
647
|
});
|
|
@@ -896,3 +1030,141 @@ test('parses empty keys', function (t) {
|
|
|
896
1030
|
});
|
|
897
1031
|
});
|
|
898
1032
|
});
|
|
1033
|
+
|
|
1034
|
+
test('`duplicates` option', function (t) {
|
|
1035
|
+
v.nonStrings.concat('not a valid option').forEach(function (invalidOption) {
|
|
1036
|
+
if (typeof invalidOption !== 'undefined') {
|
|
1037
|
+
t['throws'](
|
|
1038
|
+
function () { qs.parse('', { duplicates: invalidOption }); },
|
|
1039
|
+
TypeError,
|
|
1040
|
+
'throws on invalid option: ' + inspect(invalidOption)
|
|
1041
|
+
);
|
|
1042
|
+
}
|
|
1043
|
+
});
|
|
1044
|
+
|
|
1045
|
+
t.deepEqual(
|
|
1046
|
+
qs.parse('foo=bar&foo=baz'),
|
|
1047
|
+
{ foo: ['bar', 'baz'] },
|
|
1048
|
+
'duplicates: default, combine'
|
|
1049
|
+
);
|
|
1050
|
+
|
|
1051
|
+
t.deepEqual(
|
|
1052
|
+
qs.parse('foo=bar&foo=baz', { duplicates: 'combine' }),
|
|
1053
|
+
{ foo: ['bar', 'baz'] },
|
|
1054
|
+
'duplicates: combine'
|
|
1055
|
+
);
|
|
1056
|
+
|
|
1057
|
+
t.deepEqual(
|
|
1058
|
+
qs.parse('foo=bar&foo=baz', { duplicates: 'first' }),
|
|
1059
|
+
{ foo: 'bar' },
|
|
1060
|
+
'duplicates: first'
|
|
1061
|
+
);
|
|
1062
|
+
|
|
1063
|
+
t.deepEqual(
|
|
1064
|
+
qs.parse('foo=bar&foo=baz', { duplicates: 'last' }),
|
|
1065
|
+
{ foo: 'baz' },
|
|
1066
|
+
'duplicates: last'
|
|
1067
|
+
);
|
|
1068
|
+
|
|
1069
|
+
t.end();
|
|
1070
|
+
});
|
|
1071
|
+
|
|
1072
|
+
test('qs strictDepth option - throw cases', function (t) {
|
|
1073
|
+
t.test('throws an exception when depth exceeds the limit with strictDepth: true', function (st) {
|
|
1074
|
+
st['throws'](
|
|
1075
|
+
function () {
|
|
1076
|
+
qs.parse('a[b][c][d][e][f][g][h][i]=j', { depth: 1, strictDepth: true });
|
|
1077
|
+
},
|
|
1078
|
+
RangeError,
|
|
1079
|
+
'Should throw RangeError'
|
|
1080
|
+
);
|
|
1081
|
+
st.end();
|
|
1082
|
+
});
|
|
1083
|
+
|
|
1084
|
+
t.test('throws an exception for multiple nested arrays with strictDepth: true', function (st) {
|
|
1085
|
+
st['throws'](
|
|
1086
|
+
function () {
|
|
1087
|
+
qs.parse('a[0][1][2][3][4]=b', { depth: 3, strictDepth: true });
|
|
1088
|
+
},
|
|
1089
|
+
RangeError,
|
|
1090
|
+
'Should throw RangeError'
|
|
1091
|
+
);
|
|
1092
|
+
st.end();
|
|
1093
|
+
});
|
|
1094
|
+
|
|
1095
|
+
t.test('throws an exception for nested objects and arrays with strictDepth: true', function (st) {
|
|
1096
|
+
st['throws'](
|
|
1097
|
+
function () {
|
|
1098
|
+
qs.parse('a[b][c][0][d][e]=f', { depth: 3, strictDepth: true });
|
|
1099
|
+
},
|
|
1100
|
+
RangeError,
|
|
1101
|
+
'Should throw RangeError'
|
|
1102
|
+
);
|
|
1103
|
+
st.end();
|
|
1104
|
+
});
|
|
1105
|
+
|
|
1106
|
+
t.test('throws an exception for different types of values with strictDepth: true', function (st) {
|
|
1107
|
+
st['throws'](
|
|
1108
|
+
function () {
|
|
1109
|
+
qs.parse('a[b][c][d][e]=true&a[b][c][d][f]=42', { depth: 3, strictDepth: true });
|
|
1110
|
+
},
|
|
1111
|
+
RangeError,
|
|
1112
|
+
'Should throw RangeError'
|
|
1113
|
+
);
|
|
1114
|
+
st.end();
|
|
1115
|
+
});
|
|
1116
|
+
|
|
1117
|
+
});
|
|
1118
|
+
|
|
1119
|
+
test('qs strictDepth option - non-throw cases', function (t) {
|
|
1120
|
+
t.test('when depth is 0 and strictDepth true, do not throw', function (st) {
|
|
1121
|
+
st.doesNotThrow(
|
|
1122
|
+
function () {
|
|
1123
|
+
qs.parse('a[b][c][d][e]=true&a[b][c][d][f]=42', { depth: 0, strictDepth: true });
|
|
1124
|
+
},
|
|
1125
|
+
RangeError,
|
|
1126
|
+
'Should not throw RangeError'
|
|
1127
|
+
);
|
|
1128
|
+
st.end();
|
|
1129
|
+
});
|
|
1130
|
+
|
|
1131
|
+
t.test('parses successfully when depth is within the limit with strictDepth: true', function (st) {
|
|
1132
|
+
st.doesNotThrow(
|
|
1133
|
+
function () {
|
|
1134
|
+
var result = qs.parse('a[b]=c', { depth: 1, strictDepth: true });
|
|
1135
|
+
st.deepEqual(result, { a: { b: 'c' } }, 'Should parse correctly');
|
|
1136
|
+
}
|
|
1137
|
+
);
|
|
1138
|
+
st.end();
|
|
1139
|
+
});
|
|
1140
|
+
|
|
1141
|
+
t.test('does not throw an exception when depth exceeds the limit with strictDepth: false', function (st) {
|
|
1142
|
+
st.doesNotThrow(
|
|
1143
|
+
function () {
|
|
1144
|
+
var result = qs.parse('a[b][c][d][e][f][g][h][i]=j', { depth: 1 });
|
|
1145
|
+
st.deepEqual(result, { a: { b: { '[c][d][e][f][g][h][i]': 'j' } } }, 'Should parse with depth limit');
|
|
1146
|
+
}
|
|
1147
|
+
);
|
|
1148
|
+
st.end();
|
|
1149
|
+
});
|
|
1150
|
+
|
|
1151
|
+
t.test('parses successfully when depth is within the limit with strictDepth: false', function (st) {
|
|
1152
|
+
st.doesNotThrow(
|
|
1153
|
+
function () {
|
|
1154
|
+
var result = qs.parse('a[b]=c', { depth: 1 });
|
|
1155
|
+
st.deepEqual(result, { a: { b: 'c' } }, 'Should parse correctly');
|
|
1156
|
+
}
|
|
1157
|
+
);
|
|
1158
|
+
st.end();
|
|
1159
|
+
});
|
|
1160
|
+
|
|
1161
|
+
t.test('does not throw when depth is exactly at the limit with strictDepth: true', function (st) {
|
|
1162
|
+
st.doesNotThrow(
|
|
1163
|
+
function () {
|
|
1164
|
+
var result = qs.parse('a[b][c]=d', { depth: 2, strictDepth: true });
|
|
1165
|
+
st.deepEqual(result, { a: { b: { c: 'd' } } }, 'Should parse correctly');
|
|
1166
|
+
}
|
|
1167
|
+
);
|
|
1168
|
+
st.end();
|
|
1169
|
+
});
|
|
1170
|
+
});
|