How to handle query params
See original GitHub issueI’m pretty sure this is a bug in pathToRegExp
(why is this project not using path-to-regexp
like many other path parsers?). But if I provide the following URL: http://localhost:8989/api/book?query=:query
this gets parsed to the following regex: http:\/\/localhost:8989\/api\/book?query=(?<query>.+?(?=\/|$))\/?
You may notice that the ?
for the search string is not escaped. I believe that to be a bug in the parser. If I escape it myself, then things work just fine.
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (7 by maintainers)
Top Results From Across the Web
Query Parameters - Branch.io
Query parameters are a defined set of parameters attached to the end of a url. They are extensions of the URL that are...
Read more >Query Parameters - Routing - Ember Guides
Query params allow for additional application state to be serialized into the URL that can't otherwise fit into the path of the URL...
Read more >How can I get query string values in JavaScript?
You read/set parameters through the get(KEY) , set(KEY, VALUE) , append(KEY, VALUE) API. You can also iterate over all values for (let p...
Read more >Query Parameters - FastAPI
As query parameters are not a fixed part of a path, they can be optional and can have default values. In the example...
Read more >URLSearchParams - Web APIs - MDN Web Docs
Chrome Edge
URLSearchParams Full support. Chrome49. Toggle history Full support. Edge...
@@iterator Full support. Chrome49. Toggle history Full support. Edge...
URLSearchParams() constructor Full support. Chrome49. Toggle...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yup, this works:
Thanks!
I tried the above suggestion and that didn’t work for me. I don’t have time to investigate why (will try later) but I thought I’d let you know.