Skip to content

Commit

Permalink
[Fix] stringify: avoid encoding arrayformat comma when `encodeValue…
Browse files Browse the repository at this point in the history
…sOnly = true`

Solves 3/5 of failing tests in #410
  • Loading branch information
adnan-creator authored and ljharb committed Nov 5, 2021
1 parent 900533e commit 0377251
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/stringify.js
Expand Up @@ -102,11 +102,11 @@ var stringify = function stringify(
if (isNonNullishPrimitive(obj) || utils.isBuffer(obj)) {
if (encoder) {
var keyValue = encodeValuesOnly ? prefix : encoder(prefix, defaults.encoder, charset, 'key', format);
if(generateArrayPrefix === 'comma' && encodeValuesOnly){
const valuesArray = String(obj).split(',');
let valuesJoined = '';
if (generateArrayPrefix === 'comma' && encodeValuesOnly) {
var valuesArray = String(obj).split(',');
var valuesJoined = '';
for (var i = 0; i < valuesArray.length; ++i) {
valuesJoined = valuesJoined.concat(((i === 0)?'':',') + formatter(encoder(valuesArray[i], defaults.encoder, charset, 'value', format)));
valuesJoined = valuesJoined.concat((i === 0 ? '' : ',') + formatter(encoder(valuesArray[i], defaults.encoder, charset, 'value', format)));
}
return [formatter(keyValue) + '=' + valuesJoined];
}
Expand Down

0 comments on commit 0377251

Please sign in to comment.