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 ljharb#410
  • Loading branch information
adnan-creator authored and ljharb committed Nov 5, 2021
1 parent 364d97c commit c0a5f5c
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/stringify.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,14 @@ 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 = "";
for (var i = 0; i < valuesArray.length; ++i) {
valuesJoined = valuesJoined.concat(((i===0)?'':',') + formatter(encoder(valuesArray[i], defaults.encoder, charset, 'value', format)));
}
return [formatter(keyValue) + '=' + valuesJoined];
}
return [formatter(keyValue) + '=' + formatter(encoder(obj, defaults.encoder, charset, 'value', format))];
}
return [formatter(prefix) + '=' + formatter(String(obj))];
Expand Down

0 comments on commit c0a5f5c

Please sign in to comment.