Skip to content
Myr

misc refactoring

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 7c15cde · Browse files · 1 file+8 added−8 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+8 added−8 removed

  • other:+8 added−8 removed

1 file+8 added−8 removed

modified:lib/request.js+8 added-8 removed
96 unmodified lines
9798req.accepts = function(type){99 var accept = this.header('Accept');100101 // Normalize extensions ".json" -> "json"101 // normalize extensions ".json" -> "json"102 if (type && '.' == type[0]) type = type.substr(1);103104 // When Accept does not exist, or is '*/*' return true 104 // when Accept does not exist, or is '*/*' return true 105 if (!accept || '*/*' == accept) {106 return true;107 } else if (type) {108 // Allow "html" vs "text/html" etc108 // allow "html" vs "text/html" etc109 if (type.indexOf('/') < 0) {110 type = mime.lookup(type);111 }112113 // Check if we have a direct match113 // check if we have a direct match114 if (~accept.indexOf(type)) return true;115116 // Check if we have type/*116 // check if we have type/*117 type = type.split('/')[0] + '/*';118 return accept.indexOf(type) >= 0;119 } else {120 return false;
17 unmodified lines
138 * @api public139 */140141req.param = function(name, defaultValue){142 // Route params like /user/:id142 // route params like /user/:id143 if (this.params[name] !== undefined) {144 return this.params[name]; 145 }146 // Query string params146 // query string params147 if (this.query[name] !== undefined) {148 return this.query[name]; 149 }150 // Request body params via connect.bodyParser150 // request body params via connect.bodyParser151 if (this.body && this.body[name] !== undefined) {152 return this.body[name];153 }154 return defaultValue;
136 unmodified lines