-
-
Notifications
You must be signed in to change notification settings - Fork 731
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
qs.parse doesn't handle encoded comma when parsing array with comma option #410
Comments
The arrayFormat comma feature treats unencoded commas differently from encoded ones. Encoded commas are not special delimiters, they're just text - the Thus, if your http library always unconditionally encodes the comma, and you can't fix that, then your options are:
|
Relevant commit with the change ( We're also using qs.parse(qs.stringify({ filters: { status: ['a', 'b'] } }, { arrayFormat: 'comma' }), { comma: true });
/*
Outputs
{
"filters": {
"status": "a,b"
}
}
*/ |
I do see that
|
I've made a branch with 5 failing tests - 2 of which I don't actually know how it would be possible to represent (nested arrays inside an object using the comma format). A PR into that branch that improves the tests and/or provides a solution would be much appreciated. |
This comment has been minimized.
This comment has been minimized.
Please assign this issue to me, I am working on a PR. |
…sOnly = true` Solves 3/5 of failing tests in ljharb#410
…sOnly = true` Solves 3/5 of failing tests in ljharb#410
…sOnly = true` Solves 3/5 of failing tests in ljharb#410
…sOnly = true` Solves 3/5 of failing tests in ljharb#410
…sOnly = true` Solves 3/5 of failing tests in ljharb#410
…sOnly = true` Solves 3/5 of failing tests in #410
…sOnly = true` Solves 3/5 of failing tests in #410
Hello this is my first time opening an issue here! First of all thank you for this amazing library.
Basically my company is following jsonapi's spec for formatting filter in URL
GET /comments?filter[post]=1,2 HTTP/1.1
This works fine if the comma is not encoded
Atm our http library automatically encodes comma, which I suspect makes parse treat the comma-separated list as just a string.
This test fails and the returned array is a string,
"1,2"
.Please let me know if there's anything that I miss that would help.
P/S: After reading the source code and the tests I think maybe this feature is not supported.
If you think this is not a bug but rather a missing feature, do you think it should be included in the lib?
The text was updated successfully, but these errors were encountered: