Socket
Socket
Sign inDemoInstall

qs

Package Overview
Dependencies
0
Maintainers
3
Versions
110
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 6.3.1 to 6.4.0

.jscs.json

19

CHANGELOG.md

@@ -0,1 +1,10 @@

## **6.4.0**
- [New] `qs.stringify`: add `encodeValuesOnly` option
- [Fix] follow `allowPrototypes` option during merge (#201, #201)
- [Fix] support keys starting with brackets (#202, #200)
- [Fix] chmod a-x
- [Dev Deps] update `eslint`
- [Tests] up to `node` `v7.7`, `v6.10`,` v4.8`; disable osx builds since they block linux builds
- [eslint] reduce warnings
## **6.3.1**

@@ -27,2 +36,5 @@ - [Fix] ensure that `allowPrototypes: false` does not ever shadow Object.prototype properties (thanks, @snyk!)

## **6.2.2**
- [Fix] ensure that `allowPrototypes: false` does not ever shadow Object.prototype properties
## **6.2.1**

@@ -40,2 +52,5 @@ - [Fix] ensure `key[]=x&key[]&key[]=y` results in 3, not 2, values

## **6.1.1**
- [Fix] ensure that `allowPrototypes: false` does not ever shadow Object.prototype properties
## [**6.1.0**](https://github.com/ljharb/qs/issues?milestone=35&state=closed)

@@ -46,2 +61,6 @@ - [New] allowDots option for `stringify` (#151)

## **6.0.3**
- [Fix] ensure that `allowPrototypes: false` does not ever shadow Object.prototype properties
- [Fix] Restore `dist` directory; will be removed in v7 (#148)
## [**6.0.2**](https://github.com/ljharb/qs/issues?milestone=33&state=closed)

@@ -48,0 +67,0 @@ - Revert ES6 requirement and restore support for node down to v0.8.

38

dist/qs.js

@@ -121,3 +121,3 @@ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.Qs = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){

var parent = /^([^[]*)/;
var brackets = /(\[[^[\]]*])/;
var child = /(\[[^[\]]*])/g;

@@ -127,3 +127,4 @@

var segment = parent.exec(key);
var segment = brackets.exec(key);
var parent = segment ? key.slice(0, segment.index) : key;

@@ -133,6 +134,6 @@ // Stash the parent if it exists

var keys = [];
if (segment[1]) {
if (parent) {
// If we aren't using plain objects, optionally prefix keys
// that would overwrite object prototype properties
if (!options.plainObjects && has.call(Object.prototype, segment[1])) {
if (!options.plainObjects && has.call(Object.prototype, parent)) {
if (!options.allowPrototypes) {

@@ -143,3 +144,3 @@ return;

keys.push(segment[1]);
keys.push(parent);
}

@@ -230,2 +231,3 @@

encoder: utils.encode,
encodeValuesOnly: false,
serializeDate: function serializeDate(date) { // eslint-disable-line func-name-matching

@@ -249,3 +251,4 @@ return toISO.call(date);

serializeDate,
formatter
formatter,
encodeValuesOnly
) {

@@ -259,3 +262,3 @@ var obj = object;

if (strictNullHandling) {
return encoder ? encoder(prefix) : prefix;
return encoder && !encodeValuesOnly ? encoder(prefix) : prefix;
}

@@ -268,3 +271,4 @@

if (encoder) {
return [formatter(encoder(prefix)) + '=' + formatter(encoder(obj))];
var keyValue = encodeValuesOnly ? prefix : encoder(prefix);
return [formatter(keyValue) + '=' + formatter(encoder(obj))];
}

@@ -307,3 +311,4 @@ return [formatter(prefix) + '=' + formatter(String(obj))];

serializeDate,
formatter
formatter,
encodeValuesOnly
));

@@ -322,3 +327,4 @@ } else {

serializeDate,
formatter
formatter,
encodeValuesOnly
));

@@ -343,6 +349,7 @@ }

var encode = typeof options.encode === 'boolean' ? options.encode : defaults.encode;
var encoder = encode ? (typeof options.encoder === 'function' ? options.encoder : defaults.encoder) : null;
var encoder = typeof options.encoder === 'function' ? options.encoder : defaults.encoder;
var sort = typeof options.sort === 'function' ? options.sort : null;
var allowDots = typeof options.allowDots === 'undefined' ? false : options.allowDots;
var serializeDate = typeof options.serializeDate === 'function' ? options.serializeDate : defaults.serializeDate;
var encodeValuesOnly = typeof options.encodeValuesOnly === 'boolean' ? options.encodeValuesOnly : defaults.encodeValuesOnly;
if (typeof options.format === 'undefined') {

@@ -403,3 +410,3 @@ options.format = formats.default;

skipNulls,
encoder,
encode ? encoder : null,
filter,

@@ -409,3 +416,4 @@ sort,

serializeDate,
formatter
formatter,
encodeValuesOnly
));

@@ -451,3 +459,5 @@ }

} else if (typeof target === 'object') {
target[source] = true;
if (options.plainObjects || options.allowPrototypes || !has.call(Object.prototype, source)) {
target[source] = true;
}
} else {

@@ -454,0 +464,0 @@ return [target, source];

@@ -87,3 +87,3 @@ 'use strict';

var parent = /^([^[]*)/;
var brackets = /(\[[^[\]]*])/;
var child = /(\[[^[\]]*])/g;

@@ -93,3 +93,4 @@

var segment = parent.exec(key);
var segment = brackets.exec(key);
var parent = segment ? key.slice(0, segment.index) : key;

@@ -99,6 +100,6 @@ // Stash the parent if it exists

var keys = [];
if (segment[1]) {
if (parent) {
// If we aren't using plain objects, optionally prefix keys
// that would overwrite object prototype properties
if (!options.plainObjects && has.call(Object.prototype, segment[1])) {
if (!options.plainObjects && has.call(Object.prototype, parent)) {
if (!options.allowPrototypes) {

@@ -109,3 +110,3 @@ return;

keys.push(segment[1]);
keys.push(parent);
}

@@ -112,0 +113,0 @@

@@ -24,2 +24,3 @@ 'use strict';

encoder: utils.encode,
encodeValuesOnly: false,
serializeDate: function serializeDate(date) { // eslint-disable-line func-name-matching

@@ -43,3 +44,4 @@ return toISO.call(date);

serializeDate,
formatter
formatter,
encodeValuesOnly
) {

@@ -53,3 +55,3 @@ var obj = object;

if (strictNullHandling) {
return encoder ? encoder(prefix) : prefix;
return encoder && !encodeValuesOnly ? encoder(prefix) : prefix;
}

@@ -62,3 +64,4 @@

if (encoder) {
return [formatter(encoder(prefix)) + '=' + formatter(encoder(obj))];
var keyValue = encodeValuesOnly ? prefix : encoder(prefix);
return [formatter(keyValue) + '=' + formatter(encoder(obj))];
}

@@ -101,3 +104,4 @@ return [formatter(prefix) + '=' + formatter(String(obj))];

serializeDate,
formatter
formatter,
encodeValuesOnly
));

@@ -116,3 +120,4 @@ } else {

serializeDate,
formatter
formatter,
encodeValuesOnly
));

@@ -137,6 +142,7 @@ }

var encode = typeof options.encode === 'boolean' ? options.encode : defaults.encode;
var encoder = encode ? (typeof options.encoder === 'function' ? options.encoder : defaults.encoder) : null;
var encoder = typeof options.encoder === 'function' ? options.encoder : defaults.encoder;
var sort = typeof options.sort === 'function' ? options.sort : null;
var allowDots = typeof options.allowDots === 'undefined' ? false : options.allowDots;
var serializeDate = typeof options.serializeDate === 'function' ? options.serializeDate : defaults.serializeDate;
var encodeValuesOnly = typeof options.encodeValuesOnly === 'boolean' ? options.encodeValuesOnly : defaults.encodeValuesOnly;
if (typeof options.format === 'undefined') {

@@ -197,3 +203,3 @@ options.format = formats.default;

skipNulls,
encoder,
encode ? encoder : null,
filter,

@@ -203,3 +209,4 @@ sort,

serializeDate,
formatter
formatter,
encodeValuesOnly
));

@@ -206,0 +213,0 @@ }

@@ -34,3 +34,5 @@ 'use strict';

} else if (typeof target === 'object') {
target[source] = true;
if (options.plainObjects || options.allowPrototypes || !has.call(Object.prototype, source)) {
target[source] = true;
}
} else {

@@ -37,0 +39,0 @@ return [target, source];

@@ -5,3 +5,3 @@ {

"homepage": "https://github.com/ljharb/qs",
"version": "6.3.1",
"version": "6.4.0",
"repository": {

@@ -31,3 +31,3 @@ "type": "git",

"covert": "^1.1.0",
"eslint": "^3.15.0",
"eslint": "^3.17.0",
"evalmd": "^0.0.17",

@@ -34,0 +34,0 @@ "iconv-lite": "^0.4.15",

@@ -228,2 +228,11 @@ # qs

Encoding can be disabled for keys by setting the `encodeValuesOnly` option to `true`:
```javascript
var encodedValues = qs.stringify(
{ a: 'b', c: ['d', 'e=f'], f: [['g'], ['h']] },
{ encodeValuesOnly: true }
)
assert.equal(encodedValues,'a=b&c[0]=d&c[1]=e%3Df&f[0][0]=g&f[1][0]=h');
```
This encoding can also be replaced by a custom encoding method set as `encoder` option:

@@ -404,3 +413,3 @@

By default the encoding and decoding of characters is done in `utf-8`. If you
By default the encoding and decoding of characters is done in `utf-8`. If you
wish to encode querystrings to a different character set (i.e.

@@ -407,0 +416,0 @@ [Shift JIS](https://en.wikipedia.org/wiki/Shift_JIS)) you can use the

@@ -155,4 +155,2 @@ 'use strict';

t.deepEqual(qs.parse('a[b]=c&a=d'), { a: { b: 'c', d: true } }, 'can add keys to objects');
t.test('correctly prunes undefined values when converting an array to an object', function (st) {

@@ -445,5 +443,42 @@ st.deepEqual(qs.parse('a[2]=b&a[99999999]=c'), { a: { 2: 'b', 99999999: 'c' } });

st.deepEqual(qs.parse(']=toString'), { ']': 'toString' });
st.deepEqual(qs.parse(']]=toString'), { ']]': 'toString' });
st.deepEqual(qs.parse(']hello]=toString'), { ']hello]': 'toString' });
st.end();
});
t.test('params starting with a starting bracket', function (st) {
st.deepEqual(qs.parse('[=toString'), { '[': 'toString' });
st.deepEqual(qs.parse('[[=toString'), { '[[': 'toString' });
st.deepEqual(qs.parse('[hello[=toString'), { '[hello[': 'toString' });
st.end();
});
t.test('add keys to objects', function (st) {
st.deepEqual(
qs.parse('a[b]=c&a=d'),
{ a: { b: 'c', d: true } },
'can add keys to objects'
);
st.deepEqual(
qs.parse('a[b]=c&a=toString'),
{ a: { b: 'c' } },
'can not overwrite prototype'
);
st.deepEqual(
qs.parse('a[b]=c&a=toString', { allowPrototypes: true }),
{ a: { b: 'c', toString: true } },
'can overwrite prototype with allowPrototypes true'
);
st.deepEqual(
qs.parse('a[b]=c&a=toString', { plainObjects: true }),
{ a: { b: 'c', toString: true } },
'can overwrite prototype with plainObjects true'
);
st.end();
});
t.test('can return null objects', { skip: !Object.create }, function (st) {

@@ -450,0 +485,0 @@ var expected = Object.create(null);

@@ -538,2 +538,31 @@ 'use strict';

});
t.test('encodeValuesOnly', function (st) {
st.equal(
qs.stringify(
{ a: 'b', c: ['d', 'e=f'], f: [['g'], ['h']] },
{ encodeValuesOnly: true }
),
'a=b&c[0]=d&c[1]=e%3Df&f[0][0]=g&f[1][0]=h'
);
st.equal(
qs.stringify(
{ a: 'b', c: ['d', 'e'], f: [['g'], ['h']] }
),
'a=b&c%5B0%5D=d&c%5B1%5D=e&f%5B0%5D%5B0%5D=g&f%5B1%5D%5B0%5D=h'
);
st.end();
});
t.test('encodeValuesOnly - strictNullHandling', function (st) {
st.equal(
qs.stringify(
{ a: { b: null } },
{ encodeValuesOnly: true, strictNullHandling: true }
),
'a[b]'
);
st.end();
});
});

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc