1 /* eslint-disable capitalized-comments */
6 const assert
= require('assert');
7 const qs
= require('../index.js');
9 describe('querystring', function () {
10 describe('parse', function () {
12 it('should return empty object from no input', function () {
13 assert
.deepStrictEqual(
19 it('should return empty object from empty string', function () {
20 assert
.deepStrictEqual(
26 it('should return simple mapping', function () {
27 assert
.deepStrictEqual(
28 qs
.parse('foo=1&bar=2&baz=quux'),
37 it('should return array for repeated keys', function () {
38 assert
.deepStrictEqual(
39 qs
.parse('foo=1&foo=2&foo=quux'),
41 foo: [ '1', '2', 'quux' ],
46 it('should return null values for bare keys', function () {
47 assert
.deepStrictEqual(
48 qs
.parse('foo&foo&bar&quux'),
57 it('should handle space encodings and equals in values', function () {
58 assert
.deepStrictEqual(
59 qs
.parse('this+key=+spacey+string+;&foo=equally=string&'),
62 'this key': ' spacey string ',
63 foo: 'equally=string',
68 it('should handle raw spaces and encoded spaces', function () {
69 assert
.deepStrictEqual(
70 qs
.parse('this+has actual+spaces=but okay%20whatever'),
72 'this has actual spaces': 'but okay whatever',
77 it('should handle empty values', function () {
78 assert
.deepStrictEqual(
79 qs
.parse(';;;;;;;+;;;;'),
81 '': [ null, null, null, null, null, null, null, null, null, null, null ],
87 it('should handle PHP style array declarations', function () {
88 assert
.deepStrictEqual(
89 qs
.parse('foo%5B%5D&bar[]=1&bar[]=2&baz', true),