@@ -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
147153var 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
0 commit comments