query.js
This file
Path
lib/middleware/query.js
30 lines · 506 bytes · JavaScript
Last changed by
Add configurable query parserDouglas Christopher Wilsonbefore adoptione29fa25
History of this fileTake it
The walk stopped after 200 commits: lines older than 269dc53 point at it.
Invoke router.param() only when route matchesDouglas Christopher Wilsonbefore adoption269dc53
lines 1–5why, one step back1/**2 * Module dependencies.3 */45var parseUrl = require('parseurl');Add configurable query parserDouglas Christopher Wilsonbefore adoptione29fa25
line 6why, one step back6var qs = require('qs');Invoke router.param() only when route matchesDouglas Christopher Wilsonbefore adoption269dc53
lines 7–13why, one step back78/**9 * @param {Object} options10 * @return {Function}11 * @api public12 */13Add configurable query parserDouglas Christopher Wilsonbefore adoptione29fa25
lines 14–21why, one step back14module.exports = function query(options) {15 var queryparse = qs.parse;1617 if (typeof options === 'function') {18 queryparse = options;19 options = undefined;20 }21Invoke router.param() only when route matchesDouglas Christopher Wilsonbefore adoption269dc53
lines 22–23why, one step back22 return function query(req, res, next){23 if (!req.query) {Add configurable query parserDouglas Christopher Wilsonbefore adoptione29fa25
lines 24–25why, one step back24 var val = parseUrl(req).query;25 req.query = queryparse(val, options);Invoke router.param() only when route matchesDouglas Christopher Wilsonbefore adoption269dc53
lines 26–30why, one step back26 }2728 next();29 };30};