Skip to content
Myr

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 file

Take 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 back
1/**
2 * Module dependencies.3 */45var parseUrl = require('parseurl');

Add configurable query parserDouglas Christopher Wilsonbefore adoptione29fa25

line 6why, one step back
6var qs = require('qs');

Invoke router.param() only when route matchesDouglas Christopher Wilsonbefore adoption269dc53

lines 7–13why, one step back
7
8/**9 * @param {Object} options10 * @return {Function}11 * @api public12 */13

Add configurable query parserDouglas Christopher Wilsonbefore adoptione29fa25

lines 14–21why, one step back
14module.exports = function query(options) {
15 var queryparse = qs.parse;1617 if (typeof options === 'function') {18 queryparse = options;19 options = undefined;20 }21

Invoke router.param() only when route matchesDouglas Christopher Wilsonbefore adoption269dc53

lines 22–23why, one step back
22 return function query(req, res, next){
23 if (!req.query) {

Add configurable query parserDouglas Christopher Wilsonbefore adoptione29fa25

lines 24–25why, one step back
24 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 back
26 }
2728 next();29 };30};