|
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
-
-
- 'use strict';
-
-
-
- var merge = require('utils-merge')
- var parseUrl = require('parseurl');
- var qs = require('qs');
-
-
-
- module.exports = function query(options) {
- var opts = merge({}, options)
- var queryparse = qs.parse;
-
- if (typeof options === 'function') {
- queryparse = options;
- opts = undefined;
- }
-
- if (opts !== undefined && opts.allowPrototypes === undefined) {
-
- opts.allowPrototypes = true;
- }
-
- return function query(req, res, next){
- if (!req.query) {
- var val = parseUrl(req).query;
- req.query = queryparse(val, opts);
- }
-
- next();
- };
- };
|