Skip to content
Myr

Remove req.param()

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Douglas Christopher Wilson · committed by Douglas Christopher Wilson · parent a7d15f3 · Browse files · 3 files+1 added−96 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+1 added−96 removed

  • tests:+0 added−61 removed
  • other:+1 added−35 removed

3 files+1 added−96 removed

modified:lib/request.js-35 removed
12 unmodified lines
13 * @private14 */1516var accepts = require('accepts');17var deprecate = require('depd')('express');17var isIP = require('net').isIP;18var typeis = require('type-is');19var http = require('http');20var fresh = require('fresh');
188 unmodified lines
209 return queryparse(querystring);210});211212/**214 * Return the value of param `name` when present or `defaultValue`.215 *216 * - Checks route placeholders, ex: _/user/:id_217 * - Checks body params, ex: id=12, {"id":12}218 * - Checks query string params, ex: ?id=12219 *220 * To utilize request bodies, `req.body`221 * should be an object. This can be done by using222 * the `bodyParser()` middleware.223 *224 * @param {String} name225 * @param {Mixed} [defaultValue]226 * @return {String}227 * @public228 */229230req.param = function param(name, defaultValue) {231 var params = this.params || {};232 var body = this.body || {};233 var query = this.query || {};234235 var args = arguments.length === 1236 ? 'name'237 : 'name, default';238 deprecate('req.param(' + args + '): Use req.params, req.body, or req.query instead');239240 if (null != params[name] && params.hasOwnProperty(name)) return params[name];241 if (null != body[name]) return body[name];242 if (null != query[name]) return query[name];243244 return defaultValue;245};246247/**213 * Check if the incoming request contains the "Content-Type"214 * header field, and it contains the give mime `type`.215 *216 * Examples:
263 unmodified lines
deleted:test/req.param.js-61 removed
modified:History.md+1 added
3 unmodified lines
4This incorporates all changes after 4.10.1 up to 4.13.1.56 * remove:7 - `app.param(fn)`8 - `req.param()` -- use `req.params`, `req.body`, or `req.query` instead9 * change:10 - The leading `:` character in `name` for `app.param(name, fn)` is no longer removed11125.0.0-alpha.1 / 2014-11-06
3012 unmodified lines