Skip to content
Myr

Changed: req.accepts() utilizing utils.accepts()

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 36be2b0 · Browse files · 1 file+1 added−18 removed
This commit

State

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

Diff stats

1 file+1 added−18 removed

  • other:+1 added−18 removed

1 file+1 added−18 removed

modified:lib/request.js+1 added-18 removed
125 unmodified lines
126 * @api public127 */128129req.accepts = function(type){130 var accept = this.header('Accept')131 , type = String(type);132133 // when not present or "*/*" accept anything134 if (!accept || '*/*' == accept) return true;135136 // normalize extensions ".json" -> "json"137 if ('.' == type[0]) type = type.substr(1);138139 // allow "html" vs "text/html" etc140 if (!~type.indexOf('/')) type = mime.lookup(type);141142 // check if we have a direct match143 if (~accept.indexOf(type)) return true;144145 // check if we have type/*146 type = type.split('/')[0] + '/*';147 return !! ~accept.indexOf(type);130 return utils.accepts(type, this.header('Accept'));131};132133/**134 * Return an array of Accepted media types
302 unmodified lines