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 2ac2509 point at it.

4.13.1Douglas Christopher Wilsonbefore adoption2ac2509

lines 1–32why, 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 */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) {25 var opts = Object.create(options || null);26 var queryparse = qs.parse;2728 if (typeof options === 'function') {29 queryparse = options;30 opts = undefined;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;

4.13.1Douglas Christopher Wilsonbefore adoption2ac2509

lines 36–46why, one step back
36 }
3738 return function query(req, res, next){39 if (!req.query) {40 var val = parseUrl(req).query;41 req.query = queryparse(val, opts);42 }4344 next();45 };46};