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
If paramsSerializer is not specified, brackets are not encoded #3316
Comments
This happened due to library returns brackets after encoding Line 11 in 4b3947a
I dont know what reason to do it |
Running Tomcat 8.0.44 was fine, but after upgrading to 8.0.59, Tomcat now enforces those to be encoded. |
Regardless of server, the brackets should still be encoded by axios. |
#3477 No feedback since I created the PR, so I'm commenting the link. |
For anyone waiting for this fix to be incorporated into the next version of axios, here is a quick and dirty workaround using paramsSerializer and query-string (qs will also work) to strictly encode the URL:
|
Would greatly appreciate a merge of this PR..... :) |
Please try with the latest version, should this still be the case let me know 😄 |
Hi, tried with the latest version [v0.27.2] however, the square brackets are still not encoded. |
Please try with the pre-release v1 |
Pre-release v1 also does not seem to work. This issue also makes it impossible to interact with the patreon API since manual URL encoding with %5B and %5D doesn't work, since % gets encoded. |
This is (no longer?) correct as paramSerializer is now an object with A helpful example was provided here. I didn't have luck with import axios from 'axios';
import qs from 'qs';
const api = axios.create({
baseURL: 'http://localhost:3000',
paramsSerializer: {
serialize: (params) => {
return qs.stringify(params, { arrayFormat: 'brackets' });
},
},
}); Maybe there is a cleaner way, but this seems to work fine for me. |
@jasonsaayman Seeing as this issue has been closed for a while, I'm not sure what the intended default behavior is. But just to confirm, axios itself still does not encode brackets as of v1.3.3. |
@andrijaantunovic @jasonsaayman This issue is not resolved in the latest released version(v1.3.3), so it needs to be reopened. |
Here to report the same issue with version 1.3.4 |
Reopened |
@HealGaren |
This change to the default paramsSerializer can be consider breaking change for multiple people. |
This issue still not resolved using v1.6.2. |
Hello @jasonsaayman, is there any news on this issue ? Is #5715 planned to be merge soon ? Thanks in advance |
Describe the issue
The default behavior of paramsSerializer does not encode square brackets.
There cannot be brackets in place of the url parameter, and it should be encoded.
Looking at this pull request or this comment, This behavior seems to be intentional.
But according to the RFC 3986 cited there:
(page 19)
URL parameter is not in this case. So I think brackets should be encoded in default behavior.
Example Code
Expected behavior, if applicable
expected : request URL is
https://domain.com/test?a=%5B%5D
actual: request URL is
https://domain.com/test?a=[]
Environment
Additional context/Screenshots
The text was updated successfully, but these errors were encountered: