cdk-common 2.0.167 → 2.0.170

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.
@@ -140,6 +140,9 @@ test('parse()', function (t) {
140
140
  t.test('limits specific array indices to arrayLimit', function (st) {
141
141
  st.deepEqual(qs.parse('a[20]=a', { arrayLimit: 20 }), { a: ['a'] });
142
142
  st.deepEqual(qs.parse('a[21]=a', { arrayLimit: 20 }), { a: { 21: 'a' } });
143
+
144
+ st.deepEqual(qs.parse('a[20]=a'), { a: ['a'] });
145
+ st.deepEqual(qs.parse('a[21]=a'), { a: { 21: 'a' } });
143
146
  st.end();
144
147
  });
145
148
 
@@ -378,6 +381,7 @@ test('parse()', function (t) {
378
381
  st.deepEqual(qs.parse('?foo=bar', { ignoreQueryPrefix: true }), { foo: 'bar' });
379
382
  st.deepEqual(qs.parse('foo=bar', { ignoreQueryPrefix: true }), { foo: 'bar' });
380
383
  st.deepEqual(qs.parse('?foo=bar', { ignoreQueryPrefix: false }), { '?foo': 'bar' });
384
+
381
385
  st.end();
382
386
  });
383
387
 
@@ -406,6 +410,16 @@ test('parse()', function (t) {
406
410
  st.deepEqual(qs.parse('foo=', { comma: true }), { foo: '' });
407
411
  st.deepEqual(qs.parse('foo', { comma: true }), { foo: '' });
408
412
  st.deepEqual(qs.parse('foo', { comma: true, strictNullHandling: true }), { foo: null });
413
+
414
+ // test cases inversed from from stringify tests
415
+ st.deepEqual(qs.parse('a[0]=c'), { a: ['c'] });
416
+ st.deepEqual(qs.parse('a[]=c'), { a: ['c'] });
417
+ st.deepEqual(qs.parse('a[]=c', { comma: true }), { a: ['c'] });
418
+
419
+ st.deepEqual(qs.parse('a[0]=c&a[1]=d'), { a: ['c', 'd'] });
420
+ st.deepEqual(qs.parse('a[]=c&a[]=d'), { a: ['c', 'd'] });
421
+ st.deepEqual(qs.parse('a=c,d', { comma: true }), { a: ['c', 'd'] });
422
+
409
423
  st.end();
410
424
  });
411
425
 
@@ -131,6 +131,37 @@ test('stringify()', function (t) {
131
131
  st.end();
132
132
  });
133
133
 
134
+ t.test('stringifies an array value with one item vs multiple items', function (st) {
135
+ st.test('non-array item', function (s2t) {
136
+ s2t.equal(qs.stringify({ a: 'c' }, { encodeValuesOnly: true, arrayFormat: 'indices' }), 'a=c');
137
+ s2t.equal(qs.stringify({ a: 'c' }, { encodeValuesOnly: true, arrayFormat: 'brackets' }), 'a=c');
138
+ s2t.equal(qs.stringify({ a: 'c' }, { encodeValuesOnly: true, arrayFormat: 'comma' }), 'a=c');
139
+ s2t.equal(qs.stringify({ a: 'c' }, { encodeValuesOnly: true }), 'a=c');
140
+
141
+ s2t.end();
142
+ });
143
+
144
+ st.test('array with a single item', function (s2t) {
145
+ s2t.equal(qs.stringify({ a: ['c'] }, { encodeValuesOnly: true, arrayFormat: 'indices' }), 'a[0]=c');
146
+ s2t.equal(qs.stringify({ a: ['c'] }, { encodeValuesOnly: true, arrayFormat: 'brackets' }), 'a[]=c');
147
+ s2t.equal(qs.stringify({ a: ['c'] }, { encodeValuesOnly: true, arrayFormat: 'comma' }), 'a[]=c'); // so it parses back as an array
148
+ s2t.equal(qs.stringify({ a: ['c'] }, { encodeValuesOnly: true }), 'a[0]=c');
149
+
150
+ s2t.end();
151
+ });
152
+
153
+ st.test('array with multiple items', function (s2t) {
154
+ s2t.equal(qs.stringify({ a: ['c', 'd'] }, { encodeValuesOnly: true, arrayFormat: 'indices' }), 'a[0]=c&a[1]=d');
155
+ s2t.equal(qs.stringify({ a: ['c', 'd'] }, { encodeValuesOnly: true, arrayFormat: 'brackets' }), 'a[]=c&a[]=d');
156
+ s2t.equal(qs.stringify({ a: ['c', 'd'] }, { encodeValuesOnly: true, arrayFormat: 'comma' }), 'a=c,d');
157
+ s2t.equal(qs.stringify({ a: ['c', 'd'] }, { encodeValuesOnly: true }), 'a[0]=c&a[1]=d');
158
+
159
+ s2t.end();
160
+ });
161
+
162
+ st.end();
163
+ });
164
+
134
165
  t.test('stringifies a nested array value', function (st) {
135
166
  st.equal(qs.stringify({ a: { b: ['c', 'd'] } }, { encodeValuesOnly: true, arrayFormat: 'indices' }), 'a[b][0]=c&a[b][1]=d');
136
167
  st.equal(qs.stringify({ a: { b: ['c', 'd'] } }, { encodeValuesOnly: true, arrayFormat: 'brackets' }), 'a[b][]=c&a[b][]=d');
@@ -348,12 +379,12 @@ test('stringify()', function (t) {
348
379
  st.equal(qs.stringify({ a: [], b: [null], c: 'c' }, { encode: false, arrayFormat: 'indices' }), 'b[0]=&c=c');
349
380
  st.equal(qs.stringify({ a: [], b: [null], c: 'c' }, { encode: false, arrayFormat: 'brackets' }), 'b[]=&c=c');
350
381
  st.equal(qs.stringify({ a: [], b: [null], c: 'c' }, { encode: false, arrayFormat: 'repeat' }), 'b=&c=c');
351
- st.equal(qs.stringify({ a: [], b: [null], c: 'c' }, { encode: false, arrayFormat: 'comma' }), 'b=&c=c');
382
+ st.equal(qs.stringify({ a: [], b: [null], c: 'c' }, { encode: false, arrayFormat: 'comma' }), 'b[]=&c=c');
352
383
  // with strictNullHandling
353
384
  st.equal(qs.stringify({ a: [], b: [null], c: 'c' }, { encode: false, arrayFormat: 'indices', strictNullHandling: true }), 'b[0]&c=c');
354
385
  st.equal(qs.stringify({ a: [], b: [null], c: 'c' }, { encode: false, arrayFormat: 'brackets', strictNullHandling: true }), 'b[]&c=c');
355
386
  st.equal(qs.stringify({ a: [], b: [null], c: 'c' }, { encode: false, arrayFormat: 'repeat', strictNullHandling: true }), 'b&c=c');
356
- st.equal(qs.stringify({ a: [], b: [null], c: 'c' }, { encode: false, arrayFormat: 'comma', strictNullHandling: true }), 'b&c=c');
387
+ st.equal(qs.stringify({ a: [], b: [null], c: 'c' }, { encode: false, arrayFormat: 'comma', strictNullHandling: true }), 'b[]&c=c');
357
388
  // with skipNulls
358
389
  st.equal(qs.stringify({ a: [], b: [null], c: 'c' }, { encode: false, arrayFormat: 'indices', skipNulls: true }), 'c=c');
359
390
  st.equal(qs.stringify({ a: [], b: [null], c: 'c' }, { encode: false, arrayFormat: 'brackets', skipNulls: true }), 'c=c');
@@ -681,7 +712,7 @@ test('stringify()', function (t) {
681
712
  arrayFormat: 'comma'
682
713
  }
683
714
  ),
684
- 'a=' + date.getTime(),
715
+ 'a%5B%5D=' + date.getTime(),
685
716
  'works with arrayFormat comma'
686
717
  );
687
718
 
@@ -714,16 +745,14 @@ test('stringify()', function (t) {
714
745
  });
715
746
 
716
747
  t.test('Edge cases and unknown formats', function (st) {
717
- ['UFO1234', false, 1234, null, {}, []].forEach(
718
- function (format) {
719
- st['throws'](
720
- function () {
721
- qs.stringify({ a: 'b c' }, { format: format });
722
- },
723
- new TypeError('Unknown format option provided.')
724
- );
725
- }
726
- );
748
+ ['UFO1234', false, 1234, null, {}, []].forEach(function (format) {
749
+ st['throws'](
750
+ function () {
751
+ qs.stringify({ a: 'b c' }, { format: format });
752
+ },
753
+ new TypeError('Unknown format option provided.')
754
+ );
755
+ });
727
756
  st.end();
728
757
  });
729
758
 
package/package.json CHANGED
@@ -56,7 +56,7 @@
56
56
  "jsii-pacmak": "^1.59.0",
57
57
  "json-schema": "^0.4.0",
58
58
  "npm-check-updates": "^12",
59
- "projen": "0.57.3",
59
+ "projen": "0.57.11",
60
60
  "standard-version": "^9",
61
61
  "ts-jest": "^27",
62
62
  "typescript": "^4.7.3"
@@ -84,7 +84,7 @@
84
84
  ],
85
85
  "main": "lib/index.js",
86
86
  "license": "Apache-2.0",
87
- "version": "2.0.167",
87
+ "version": "2.0.170",
88
88
  "jest": {
89
89
  "testMatch": [
90
90
  "<rootDir>/src/**/__tests__/**/*.ts?(x)",
@@ -140,12 +140,12 @@
140
140
  "rootDir": "src"
141
141
  }
142
142
  },
143
- "resolutions": {
144
- "@types/prettier": "2.6.0"
145
- },
146
143
  "awscdkio": {
147
144
  "twitter": "neil_kuan",
148
145
  "announce": true
149
146
  },
147
+ "resolutions": {
148
+ "@types/prettier": "2.6.0"
149
+ },
150
150
  "//": "~~ Generated by projen. To modify, edit .projenrc.js and run \"npx projen\"."
151
151
  }
package/changelog.md DELETED
@@ -1,2 +0,0 @@
1
-
2
- ### [2.0.167](https://github.com/neilkuan/cdk-common/compare/v2.0.166...v2.0.167) (2022-06-05)
package/releasetag.txt DELETED
@@ -1 +0,0 @@
1
- v2.0.167
package/version.txt DELETED
@@ -1 +0,0 @@
1
- 2.0.167