question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

If paramsSerializer is not specified, brackets are not encoded

See original GitHub issue

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:

A host identified by an Internet Protocol literal address, version 6 [RFC3513] or later, is distinguished by enclosing the IP literal within square brackets (“[” and “]”). This is the only place where square bracket characters are allowed in the URI syntax.

(page 19)

URL parameter is not in this case. So I think brackets should be encoded in default behavior.

Example Code

axios.get('/test', {params: {a: '[]'}})

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

  • Axios Version: 0.20.0
  • Browser: Chrome
  • Browser Version: 85.0.4183.121

Additional context/Screenshots

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:8
  • Comments:11 (2 by maintainers)

github_iconTop GitHub Comments

6reactions
stevebor1commented, Mar 19, 2021

Regardless of server, the brackets should still be encoded by axios. What is the status of this?

5reactions
aLx450commented, Sep 30, 2021

Would greatly appreciate a merge of this PR… 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

If paramsSerializer is not specified, brackets are not encoded
Describe the issue. The default behavior of paramsSerializer does not encode square brackets. There cannot be brackets in place of the url ...
Read more >
How to correctly use axios params with arrays - Stack Overflow
I tried qs but it is not compatible with my python connexion backend (for JSON string parameters). const rcg = axios.create({ baseURL: `${url}/ ......
Read more >
API Returning Empty Attributes for Members - Friendly Help
Been working with the v1 API for a bit and now am attempting to get some v2 calls working. The following command is...
Read more >
Axios Cheat Sheet - Kapeli - Dash for macOS
Make a request for a user with a given ID axios.get('/user? ... 'POST', and 'PATCH' // When no `transformRequest` is set, must be...
Read more >
Request Config | Axios 中文文档
Requests will default to GET if method is not specified. ... `paramsSerializer` is an optional function in charge of serializing `params` // (e.g. ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found