-
Notifications
You must be signed in to change notification settings - Fork 14.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
request.query behaves immutable in 5.x #2752
Comments
Hi! Yes, this is expected behavior and is one of the breaking changes, listed in the History file as follows:
In Express 5,
|
Gotcha, thanks this is helpful, is this change to reflect a more functional style of programming per chance? Do changes made into req.url reflect back onto req.query? How might a person trigger the rebuild of the req.query after a change to req.url has been made? |
Hi! So the changes you make to req.url are instantly reflected in req.query (but you have to call req.query after the change--the object you got doesn't auto-update). |
@dougwilson sorry for asking here, but it is not clear to me: var RQL = function (req, res, next) {
var qStr = url.parse(req.originalUrl).search.substr(1);
req.query = (!qStr.length) ? {} : rql.parseQuery(qStr);
next();
};
app.use(RQL); ? |
Hi @sebilasse , you want to use the // In Express 4.x, this has to be set before you define your first route; in 5.x you can set at any time
app.set('query parser', function (str) {
return str.length ? rql.parseQuery(str) : {};
}); |
Tested against 4.13, request.query is tested false for Object.isFrozen and also does not pass this test assuming HTTP GET:
The text was updated successfully, but these errors were encountered: