diff options
Diffstat (limited to 'vnfmarket/src/main/webapp/vnfmarket/node_modules/connect/lib/middleware/query.js')
-rw-r--r-- | vnfmarket/src/main/webapp/vnfmarket/node_modules/connect/lib/middleware/query.js | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/vnfmarket/src/main/webapp/vnfmarket/node_modules/connect/lib/middleware/query.js b/vnfmarket/src/main/webapp/vnfmarket/node_modules/connect/lib/middleware/query.js new file mode 100644 index 00000000..64448e4e --- /dev/null +++ b/vnfmarket/src/main/webapp/vnfmarket/node_modules/connect/lib/middleware/query.js @@ -0,0 +1,45 @@ +/*! + * Connect - query + * Copyright(c) 2011 TJ Holowaychuk + * Copyright(c) 2011 Sencha Inc. + * MIT Licensed + */ + +/** + * Module dependencies. + */ + +var parseurl = require('parseurl'); +var qs = require('qs'); + +/** + * Query: + * + * Automatically parse the query-string when available, + * populating the `req.query` object using + * [qs](https://github.com/visionmedia/node-querystring). + * + * Examples: + * + * connect() + * .use(connect.query()) + * .use(function(req, res){ + * res.end(JSON.stringify(req.query)); + * }); + * + * @param {Object} options + * @return {Function} + * @api public + */ + +module.exports = function query(){ + return function query(req, res, next){ + if (!req.query) { + req.query = ~req.url.indexOf('?') + ? qs.parse(parseurl(req).query, { allowDots: false, allowPrototypes: true }) + : {}; + } + + next(); + }; +}; |