Comments (4)
Hi @alxndrsn thanks for reporting this issue.
Indeed, Express.js by default uses qs
instead of querystring
.
I agree that for better compatibility node-mocks-http
should also use qs
.
Since this project relies a lot on contributors, we'd really appreciate it if you could come up with a fix. Thanks a bunch!
from node-mocks-http.
I agree that for better compatibility
node-mocks-http
should also useqs
.
That's not what I'm suggesting - I think doing any parsing of query strings is going to give misleading results for some users in some situations.
Here are the parsers used by the frameworks listed in https://github.com/eugef/node-mocks-http/blob/master/README.md:
library | parser | docs |
---|---|---|
expressjs ("extended"/default) | qs |
https://expressjs.com/en/api.html#app.set |
expressjs ("simple") | querystring |
https://expressjs.com/en/api.html#app.set |
NextJS | URLSearchParams |
https://nextjs.org/docs/app/api-reference/functions/use-search-params |
Koa (default) | querystring |
https://github.com/koajs/koa/blob/master/lib/request.js#L13 |
Safe approaches might be to:
- deprecate query string parsing in this library and log a warning
- remove query string parsing from this library
- require explicit configuration of a particular parser
- allow some way to derive which parser to use from a user-supplied application instance
Option 2 would seem the simplest & safest, with obvious inconvenience for anyone using this feature.
from node-mocks-http.
Stale issue message
from node-mocks-http.
To keep library backwards compatible we will continue using built-in querystring
but add a configuration option to allow using other parsing libs
from node-mocks-http.
Related Issues (20)
- @types/express 3.17.15 -> Request/Response mismatch HOT 5
- Importing produces ESlint warning `import/named` HOT 7
- Timeouts when using with formidable HOT 1
- Tests started to fail when using node 16 to run then and works when use node 14 HOT 1
- Provide decorator for stream consumer through pipe HOT 2
- Any plans to add async iterator support to IncomingMessage? HOT 5
- Let mock request extend stream.Readable or even http.IncomingMessage HOT 4
- `node-mocks-http` doesn't work with NextJS requests HOT 2
- subdomains property in the request not supported HOT 1
- Unexpected end of JSON input with async express router HOT 4
- What happens if you have a database call in your handler? HOT 2
- @types/express should be a non-dev dependency HOT 1
- Deprecate `lib/express` HOT 3
- 'links' function not defined HOT 3
- Not compatible with the Next.js "app" router HOT 3
- Question: How to mock an request error? HOT 2
- how to create error response? HOT 4
- The `sendFile` property is missing HOT 2
- No way to get data written to response
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-mocks-http.