query.js
This file
Path
lib/middleware/query.js
40 lines · 687 bytes · JavaScript
Last changed by
perf: enable strict modeDouglas Christopher Wilsonbefore adoptione71014f
History of this fileTake it
1234567891011121314151617181920212223242526272829303132333435363738394041/*! * express * Copyright(c) 2009-2013 TJ Holowaychuk * Copyright(c) 2013 Roman Shtylman * Copyright(c) 2014-2015 Douglas Christopher Wilson * MIT Licensed */
'use strict';
/** * Module dependencies. */
var parseUrl = require('parseurl');var qs = require('qs');
/** * @param {Object} options * @return {Function} * @api public */
module.exports = function query(options) { var queryparse = qs.parse;
if (typeof options === 'function') { queryparse = options; options = undefined; }
return function query(req, res, next){ if (!req.query) { var val = parseUrl(req).query; req.query = queryparse(val, options); }
next(); };};