nodejs (express) is it possible to have case insensitive querystring?

express, node.js

Solution

It's not possible as-is, but you could insert a very simple middleware which would, for instance, lowercase all keys in `req.query`:

// insert this before your routes
app.use(function(req, res, next) {
  for (var key in req.query)
  { 
    req.query[key.toLowerCase()] = req.query[key];
  }
  next();
});

Problem

It seems that querystring is case sensitive. Is it possible to have a case insensitive querystring? If my url has `?Id=10`, accessing `req.query.id` returns `undefined`.

Original source