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.

Encoding of space in query

See original GitHub issue

Hi

I have a problem. axios sends queries there space is encoded as + like

http://localhost:8080/abd/lucat/employees?search=Fredrik+Johansson&limit=10

and this results in an error from express-openapi-validator:

{"path":".query.search","message":"Parameter 'search' must be url encoded. It's value may not contain reserved characters."}

The line here includes + as a reserved character in queries https://github.com/cdimascio/express-openapi-validator/blob/master/src/middlewares/parsers/req.parameter.mutator.ts#L18

axios seems to working on this because even thou + is a standard is it several systems which don’t handle this. https://github.com/axios/axios/pull/2563

So how will you handle this?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
cdimasciocommented, Nov 19, 2020

In order to use reserved characters in query paramus, you can set allowReserved: true on the query parameter. https://swagger.io/docs/specification/describing-parameters/

e.g.

parameters:
  - in: query
    name: path
    required: true
    schema:
        type: string
    allowReserved: true    
0reactions
johandalabackacommented, Nov 19, 2020

Very good. Thank you 😊❤️

Read more comments on GitHub >

github_iconTop Results From Across the Web

In a URL, should spaces be encoded using %20 or +?
Within the query string, the plus sign is reserved as shorthand notation for a space. Therefore, real plus signs must be encoded. This...
Read more >
URLEncoding of spaces in query parameters + vs %20
My problem is that any space is automatically encoded as a + and not as %20. While it is not necessarily wrong for...
Read more >
Spaces and Uppercase characters in URLs - SISTRIX
Depending on the position of the spaces in a URL, different rules apply with regard to how those spaces are properly encoded. Uppercase...
Read more >
Use %20 instead of + to encode spaces when submitting a ...
When I create the get request with query parameter that contains the space then it automatically encoded as a + and not as...
Read more >
Solved: Handling white spaces in query params
RFC 3986 specifically omits spaces as valid elements of a URI. Typically user-agents will encode your URI for you when they encounter a...
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