github.com/emc-advanced-dev/unik@v0.0.0-20190717152701-a58d3e8e33b7/docs/examples/example-nodejs-fileserver/node_modules/express/lib/middleware/query.js (about) 1 /*! 2 * express 3 * Copyright(c) 2009-2013 TJ Holowaychuk 4 * Copyright(c) 2013 Roman Shtylman 5 * Copyright(c) 2014-2015 Douglas Christopher Wilson 6 * MIT Licensed 7 */ 8 9 'use strict'; 10 11 /** 12 * Module dependencies. 13 */ 14 15 var parseUrl = require('parseurl'); 16 var qs = require('qs'); 17 18 /** 19 * @param {Object} options 20 * @return {Function} 21 * @api public 22 */ 23 24 module.exports = function query(options) { 25 var opts = Object.create(options || null); 26 var queryparse = qs.parse; 27 28 if (typeof options === 'function') { 29 queryparse = options; 30 opts = undefined; 31 } 32 33 if (opts !== undefined) { 34 if (opts.allowDots === undefined) { 35 opts.allowDots = false; 36 } 37 38 if (opts.allowPrototypes === undefined) { 39 opts.allowPrototypes = true; 40 } 41 } 42 43 return function query(req, res, next){ 44 if (!req.query) { 45 var val = parseUrl(req).query; 46 req.query = queryparse(val, opts); 47 } 48 49 next(); 50 }; 51 };