Skip to content

If paramsSerializer is not specified, brackets are not encoded #3316

@HealGaren

Description

@HealGaren

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions