Fixes the issue of stringify encoding comma(used to join array) even when encodeValuesOnly = true#424
Conversation
ljharb
left a comment
There was a problem hiding this comment.
I rebased this on top of my failing tests branch; take a look at the failures. The ??? will need to be updated to an actual expected value.
368880f to
a360d76
Compare
ljharb
left a comment
There was a problem hiding this comment.
Overall this looks great!
Are there any additional test cases we should be adding to make sure this is doing both what the issue participants expect, and what we expect?
|
Thanks! for now these tests seem fine. |
…sOnly = true` Fixes ljharb#410
Codecov Report
@@ Coverage Diff @@
## master #424 +/- ##
=======================================
Coverage 99.78% 99.78%
=======================================
Files 8 8
Lines 1388 1393 +5
Branches 167 169 +2
=======================================
+ Hits 1385 1390 +5
Misses 3 3
Continue to review full report at Codecov.
|
Following changes were made:
encodeValuesOnly = true, then all characters except the values must not be encoded. This includes brackets and joining characters such as comma. It works perfectly for all other characters except when comma is used to join elements of an array. Then even the comma is encoded.qs.stringify({ a: ['b', 'c', 'd'] }, { arrayFormat: 'comma' })to be equal to'a=b,c,d'. Which is not the expected behavior as for the comma to not be encoded we must either setencode: falseorencodeValuesOnly: true. So the right result would be'a=b%2Cc%2Cd'as the default functionality of the function is to encode the complete string.