Skip to content

Commit

Permalink
make parseQuery also set req.path and req.query; 0.9.0
Browse files Browse the repository at this point in the history
  • Loading branch information
andrasq committed Mar 25, 2021
1 parent 527c79d commit cd4f61e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ tests or benchmarks, check out the repo from https://github.com/andrasq/node-mic
Change Log
----------

- 0.9.0 - have parseQuery also set `req.path` and `req.query`
- 0.8.3 - speed access to req.params et al, req.destroy() if bodySizeLimit exceeded
- 0.8.2 - fix HttpError message text, mw.buildDecodeBody
- 0.8.1 - transfer statusCode properties onto HttpError
Expand Down
10 changes: 4 additions & 6 deletions mw.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,14 +197,12 @@ function buildParseQuery( options ) {
var hmark = req.url.indexOf('#', qmark + 1);
hmark = (hmark >= 0) ? hmark : req.url.length;
qmark = (qmark >= 0) ? qmark : hmark;
// TODO: req.path = req.url.slice(0, qmark);
// TODO: req.query = req.url.slice(qmark + 1, hmark);
req.path = req.url.slice(0, qmark);
req.query = req.url.slice(qmark + 1, hmark);
req.params = req.params || {};
// TODO: if (qmark >= req.url.length) return next();
// TODO: var query = mw.parseQuery(req.query);
var query = mw.parseQuery(qmark < hmark ? req.url.slice(qmark + 1, hmark) : '');
var query = req.query ? mw.parseQuery(req.query) : false;
// TODO: express sets query[k]
for (var k in query) req.params[k] = query[k];
if (query) for (var k in query) req.params[k] = query[k];
next();
}
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "microrest",
"version": "0.8.3",
"version": "0.9.0",
"description": "tiny embeddable REST web framework",
"keywords": ["micro", "nano", "framework", "middleware", "REST", "embeddable", "fast"],
"main": "index.js",
Expand Down

0 comments on commit cd4f61e

Please sign in to comment.