query.js
This file
Path
lib/middleware/query.js
46 lines · 863 bytes · JavaScript
Last changed by
deps: qs@6.2.0Douglas Christopher Wilsonbefore adoption999546d
History of this fileTake it
The walk stopped after 200 commits: lines older than 2a45589 point at it.
Add settings to debug outputDouglas Christopher Wilsonbefore adoption2a45589
lines 1–24why, one step back1/*!2 * express3 * Copyright(c) 2009-2013 TJ Holowaychuk4 * Copyright(c) 2013 Roman Shtylman5 * Copyright(c) 2014-2015 Douglas Christopher Wilson6 * MIT Licensed7 */89'use strict';1011/**12 * Module dependencies.13 */1415var parseUrl = require('parseurl');16var qs = require('qs');1718/**19 * @param {Object} options20 * @return {Function}21 * @api public22 */2324module.exports = function query(options) {deps: qs@4.0.0Douglas Christopher Wilsonbefore adoption7bea53b
line 25why, one step back25 var opts = Object.create(options || null);Add settings to debug outputDouglas Christopher Wilsonbefore adoption2a45589
lines 26–29why, one step back26 var queryparse = qs.parse;2728 if (typeof options === 'function') {29 queryparse = options;deps: qs@4.0.0Douglas Christopher Wilsonbefore adoption7bea53b
line 30why, one step back30 opts = undefined;Add settings to debug outputDouglas Christopher Wilsonbefore adoption2a45589
lines 31–32why, one step back31 }32deps: qs@6.2.0Douglas Christopher Wilsonbefore adoption999546d
lines 33–35why, one step back33 if (opts !== undefined && opts.allowPrototypes === undefined) {34 // back-compat for qs module35 opts.allowPrototypes = true;deps: qs@4.0.0Douglas Christopher Wilsonbefore adoption7bea53b
lines 36–37why, one step back36 }37Add settings to debug outputDouglas Christopher Wilsonbefore adoption2a45589
lines 38–40why, one step back38 return function query(req, res, next){39 if (!req.query) {40 var val = parseUrl(req).query;deps: qs@4.0.0Douglas Christopher Wilsonbefore adoption7bea53b
line 41why, one step back41 req.query = queryparse(val, opts);Add settings to debug outputDouglas Christopher Wilsonbefore adoption2a45589
lines 42–46why, one step back42 }4344 next();45 };46};