• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2require('../common');
3const assert = require('assert');
4const qs = require('querystring');
5
6function check(actual, expected) {
7  assert(!(actual instanceof Object));
8  assert.deepStrictEqual(Object.keys(actual).sort(),
9                         Object.keys(expected).sort());
10  Object.keys(expected).forEach(function(key) {
11    assert.deepStrictEqual(actual[key], expected[key]);
12  });
13}
14
15check(qs.parse('foo=>bar&&bar=>baz', '&&', '=>'),
16      { foo: 'bar', bar: 'baz' });
17
18check(qs.stringify({ foo: 'bar', bar: 'baz' }, '&&', '=>'),
19      'foo=>bar&&bar=>baz');
20
21check(qs.parse('foo==>bar, bar==>baz', ', ', '==>'),
22      { foo: 'bar', bar: 'baz' });
23
24check(qs.stringify({ foo: 'bar', bar: 'baz' }, ', ', '==>'),
25      'foo==>bar, bar==>baz');
26