Sha256: febf270f867d592cf8063bcd19fd45f98197ee5ef717f8800123020f632ac33a

Contents?: true

Size: 832 Bytes

Versions: 17

Compression:

Stored size: 832 Bytes

Contents

/*!
 * Connect - query
 * Copyright(c) 2011 TJ Holowaychuk
 * Copyright(c) 2011 Sencha Inc.
 * MIT Licensed
 */

/**
 * Module dependencies.
 */

var qs = require('qs')
  , parseurl = require('parseurl');

/**
 * 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)
        : {};
    }

    next();
  };
};

Version data entries

17 entries across 17 versions & 2 rubygems

Version Path
hooch-0.4.2 jasmine/node_modules/karma/node_modules/connect/lib/middleware/query.js
hooch-0.4.1 jasmine/node_modules/karma/node_modules/connect/lib/middleware/query.js
hooch-0.4.0 jasmine/node_modules/karma/node_modules/connect/lib/middleware/query.js
hooch-0.3.0 jasmine/node_modules/karma/node_modules/connect/lib/middleware/query.js
hooch-0.2.1 jasmine/node_modules/karma/node_modules/connect/lib/middleware/query.js
hooch-0.2.0 jasmine/node_modules/karma/node_modules/connect/lib/middleware/query.js
hooch-0.1.0 jasmine/node_modules/karma/node_modules/connect/lib/middleware/query.js
hooch-0.0.8 jasmine/node_modules/karma/node_modules/connect/lib/middleware/query.js
hooch-0.0.7 jasmine/node_modules/karma/node_modules/connect/lib/middleware/query.js
hooch-0.0.6 jasmine/node_modules/karma/node_modules/connect/lib/middleware/query.js
entangled-0.0.16 spec/dummy/public/node_modules/karma/node_modules/connect/lib/middleware/query.js
entangled-0.0.15 spec/dummy/public/node_modules/karma/node_modules/connect/lib/middleware/query.js
entangled-0.0.14 spec/dummy/public/node_modules/karma/node_modules/connect/lib/middleware/query.js
entangled-0.0.13 spec/dummy/public/node_modules/karma/node_modules/connect/lib/middleware/query.js
entangled-0.0.12 spec/dummy/public/node_modules/karma/node_modules/connect/lib/middleware/query.js
entangled-0.0.11 spec/dummy/public/node_modules/karma/node_modules/connect/lib/middleware/query.js
entangled-0.0.10 spec/dummy/public/node_modules/karma/node_modules/connect/lib/middleware/query.js