3 * Copyright(c) 2009-2013 TJ Holowaychuk
4 * Copyright(c) 2013 Roman Shtylman
5 * Copyright(c) 2014-2015 Douglas Christopher Wilson
12 * Module dependencies.
15 var merge = require('utils-merge')
16 var parseUrl = require('parseurl');
17 var qs = require('qs');
20 * @param {Object} options
25 module.exports = function query(options) {
26 var opts = merge({}, options)
27 var queryparse = qs.parse;
29 if (typeof options === 'function') {
34 if (opts !== undefined && opts.allowPrototypes === undefined) {
35 // back-compat for qs module
36 opts.allowPrototypes = true;
39 return function query(req, res, next){
41 var val = parseUrl(req).query;
42 req.query = queryparse(val, opts);