Skip to content
Myr

Removed `req.header()` defaultValue support

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

authored by TJ Holowaychuk · committed by TJ Holowaychuk · parent 8de3ad5 · Browse files · 2 files+43 added−9 removed
This commit

State

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

Diff stats

2 files+43 added−9 removed

  • tests:+39 added−0 removed
  • other:+4 added−9 removed

2 files+43 added−9 removed

modified:lib/request.js+4 added-9 removed
36 unmodified lines
37 * 38 * req.header('content-type');39 * // => "text/plain"40 * 41 * req.header('Accept');41 * req.header('Something');42 * // => undefined43 * 44 * req.header('Accept', 'text/html');45 * // => "text/html"46 *44 * @param {String} name48 * @param {String} defaultValue45 * @return {String} 46 * @api public47 */4853req.header = function(name, defaultValue){49req.header = function(name){50 switch (name = name.toLowerCase()) {51 case 'referer':52 case 'referrer':53 return this.headers.referrer58 || this.headers.referer59 || defaultValue;54 || this.headers.referer;55 default:61 return this.headers[name] || defaultValue;56 return this.headers[name];57 }58};5960/**
323 unmodified lines
added:test/req.header.js+39 added