Skip to content
Myr

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 file

Take it

The walk stopped after 200 commits: lines older than e03ed05 point at it.

docs: add license commentsDouglas Christopher Wilsonbefore adoption95ad276

lines 1–8why, one step back
1/*!
2 * express3 * Copyright(c) 2009-2013 TJ Holowaychuk4 * Copyright(c) 2013 Roman Shtylman5 * Copyright(c) 2014-2015 Douglas Christopher Wilson6 * MIT Licensed7 */8

perf: enable strict modeDouglas Christopher Wilsonbefore adoptione71014f

lines 9–10why, one step back
9'use strict';
10

deps: type-is@~1.6.0Douglas Christopher Wilsonbefore adoptione03ed05

lines 11–24why, one step back
11/**
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 back
25 var opts = Object.create(options || null);

deps: type-is@~1.6.0Douglas Christopher Wilsonbefore adoptione03ed05

lines 26–29why, one step back
26 var queryparse = qs.parse;
2728 if (typeof options === 'function') {29 queryparse = options;

deps: qs@4.0.0Douglas Christopher Wilsonbefore adoption7bea53b

line 30why, one step back
30 opts = undefined;

deps: type-is@~1.6.0Douglas Christopher Wilsonbefore adoptione03ed05

lines 31–32why, one step back
31 }
32

deps: qs@6.2.0Douglas Christopher Wilsonbefore adoption999546d

lines 33–35why, one step back
33 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 back
36 }
37

deps: type-is@~1.6.0Douglas Christopher Wilsonbefore adoptione03ed05

lines 38–40why, one step back
38 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 back
41 req.query = queryparse(val, opts);

deps: type-is@~1.6.0Douglas Christopher Wilsonbefore adoptione03ed05

lines 42–46why, one step back
42 }
4344 next();45 };46};