From ddc1ff9ca16a4b8963d7cf72d0a881732e54b8c9 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sun, 22 Mar 2020 00:14:49 -0700 Subject: [PATCH] v6.9.2 --- CHANGELOG.md | 9 +++++++++ dist/qs.js | 16 +++++++++++----- package.json | 2 +- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5591d202..cf0643af 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,12 @@ +## **6.9.2** +- [Fix] `parse`: Fix parsing array from object with `comma` true (#359) +- [Fix] `parse`: throw a TypeError instead of an Error for bad charset (#349) +- [meta] ignore eclint transitive audit warning +- [meta] fix indentation in package.json +- [meta] add tidelift marketing copy +- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `object-inspect`, `has-symbols`, `tape`, `mkdirp`, `iconv-lite` +- [actions] add automatic rebasing / merge commit blocking + ## **6.9.1** - [Fix] `parse`: with comma true, handle field that holds an array of arrays (#335) - [Fix] `parse`: with comma true, do not split non-string values (#334) diff --git a/dist/qs.js b/dist/qs.js index 602c3a68..2d78d97a 100644 --- a/dist/qs.js +++ b/dist/qs.js @@ -71,6 +71,14 @@ var interpretNumericEntities = function (str) { }); }; +var parseArrayValue = function (val, options) { + if (val && typeof val === 'string' && options.comma && val.indexOf(',') > -1) { + return val.split(','); + } + + return val; +}; + // This is what browsers will submit when the ✓ character occurs in an // application/x-www-form-urlencoded body and the encoding of the page containing // 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) { val = interpretNumericEntities(val); } - if (val && typeof val === 'string' && options.comma && val.indexOf(',') > -1) { - val = val.split(','); - } + val = parseArrayValue(val, options); if (part.indexOf('[]=') > -1) { val = isArray(val) ? [val] : val; @@ -145,7 +151,7 @@ var parseValues = function parseQueryStringValues(str, options) { }; var parseObject = function (chain, val, options) { - var leaf = val; + var leaf = parseArrayValue(val, options); for (var i = chain.length - 1; i >= 0; --i) { var obj; @@ -243,7 +249,7 @@ var normalizeParseOptions = function normalizeParseOptions(opts) { } if (typeof opts.charset !== 'undefined' && opts.charset !== 'utf-8' && opts.charset !== 'iso-8859-1') { - throw new Error('The charset option must be either utf-8, iso-8859-1, or undefined'); + throw new TypeError('The charset option must be either utf-8, iso-8859-1, or undefined'); } var charset = typeof opts.charset === 'undefined' ? defaults.charset : opts.charset; diff --git a/package.json b/package.json index 9befdbe6..c1611cba 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "qs", "description": "A querystring parser that supports nesting and arrays, with a depth limit", "homepage": "https://github.com/ljharb/qs", - "version": "6.9.1", + "version": "6.9.2", "repository": { "type": "git", "url": "https://github.com/ljharb/qs.git"