Skip to content

Commit ddc1ff9

Browse files
committed
v6.9.2
1 parent 911efab commit ddc1ff9

File tree

3 files changed

+21
-6
lines changed

3 files changed

+21
-6
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
## **6.9.2**
2+
- [Fix] `parse`: Fix parsing array from object with `comma` true (#359)
3+
- [Fix] `parse`: throw a TypeError instead of an Error for bad charset (#349)
4+
- [meta] ignore eclint transitive audit warning
5+
- [meta] fix indentation in package.json
6+
- [meta] add tidelift marketing copy
7+
- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `object-inspect`, `has-symbols`, `tape`, `mkdirp`, `iconv-lite`
8+
- [actions] add automatic rebasing / merge commit blocking
9+
110
## **6.9.1**
211
- [Fix] `parse`: with comma true, handle field that holds an array of arrays (#335)
312
- [Fix] `parse`: with comma true, do not split non-string values (#334)

dist/qs.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,14 @@ var interpretNumericEntities = function (str) {
7171
});
7272
};
7373

74+
var parseArrayValue = function (val, options) {
75+
if (val && typeof val === 'string' && options.comma && val.indexOf(',') > -1) {
76+
return val.split(',');
77+
}
78+
79+
return val;
80+
};
81+
7482
// This is what browsers will submit when the ✓ character occurs in an
7583
// application/x-www-form-urlencoded body and the encoding of the page containing
7684
// the form is iso-8859-1, or when the submitted form has an accept-charset
@@ -126,9 +134,7 @@ var parseValues = function parseQueryStringValues(str, options) {
126134
val = interpretNumericEntities(val);
127135
}
128136

129-
if (val && typeof val === 'string' && options.comma && val.indexOf(',') > -1) {
130-
val = val.split(',');
131-
}
137+
val = parseArrayValue(val, options);
132138

133139
if (part.indexOf('[]=') > -1) {
134140
val = isArray(val) ? [val] : val;
@@ -145,7 +151,7 @@ var parseValues = function parseQueryStringValues(str, options) {
145151
};
146152

147153
var parseObject = function (chain, val, options) {
148-
var leaf = val;
154+
var leaf = parseArrayValue(val, options);
149155

150156
for (var i = chain.length - 1; i >= 0; --i) {
151157
var obj;
@@ -243,7 +249,7 @@ var normalizeParseOptions = function normalizeParseOptions(opts) {
243249
}
244250

245251
if (typeof opts.charset !== 'undefined' && opts.charset !== 'utf-8' && opts.charset !== 'iso-8859-1') {
246-
throw new Error('The charset option must be either utf-8, iso-8859-1, or undefined');
252+
throw new TypeError('The charset option must be either utf-8, iso-8859-1, or undefined');
247253
}
248254
var charset = typeof opts.charset === 'undefined' ? defaults.charset : opts.charset;
249255

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "qs",
33
"description": "A querystring parser that supports nesting and arrays, with a depth limit",
44
"homepage": "https://github.com/ljharb/qs",
5-
"version": "6.9.1",
5+
"version": "6.9.2",
66
"repository": {
77
"type": "git",
88
"url": "https://github.com/ljharb/qs.git"

0 commit comments

Comments
 (0)