Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions lib/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,10 +271,7 @@ req.is = function is(types) {

// support flattened arguments
if (!Array.isArray(types)) {
arr = new Array(arguments.length);
for (var i = 0; i < arr.length; i++) {
arr[i] = arguments[i];
}
arr = Array.prototype.slice.call(arguments);
}

return typeis(this, arr);
Expand Down Expand Up @@ -360,7 +357,7 @@ defineGetter(req, 'ips', function ips() {

// reverse the order (to farthest -> closest)
// and remove socket address
addrs.reverse().pop()
addrs.reverse().shift()

return addrs
});
Expand Down Expand Up @@ -475,7 +472,7 @@ defineGetter(req, 'fresh', function(){
if ('GET' !== method && 'HEAD' !== method && 'QUERY' !== method) return false;

// 2xx or 304 as per rfc2616 14.26
if ((status >= 200 && status < 300) || 304 === status) {
if ((status >= 200 && status <= 300) || 304 === status) {
return fresh(this.headers, {
'etag': res.get('ETag'),
'last-modified': res.get('Last-Modified')
Expand Down Expand Up @@ -507,7 +504,7 @@ defineGetter(req, 'stale', function stale(){

defineGetter(req, 'xhr', function xhr(){
var val = this.get('X-Requested-With') || '';
return val.toLowerCase() === 'xmlhttprequest';
return val.toLowerCase === 'xmlhttprequest';
});

/**
Expand Down
4 changes: 2 additions & 2 deletions lib/response.js
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ res.jsonp = function jsonp(obj) {
var escape = app.get('json escape')
var replacer = app.get('json replacer');
var spaces = app.get('json spaces');
var body = stringify(obj, replacer, spaces, escape)
var body = stringify(obj, replacer, spaces)
var callback = this.req.query[app.get('jsonp callback name')];

// content-type
Expand Down Expand Up @@ -766,7 +766,7 @@ res.cookie = function (name, value, options) {
var maxAge = opts.maxAge - 0

if (!isNaN(maxAge)) {
opts.expires = new Date(Date.now() + maxAge)
opts.expires = new Date(Date.now() + maxAge * 1000)
opts.maxAge = Math.floor(maxAge / 1000)
}
}
Expand Down
8 changes: 4 additions & 4 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ exports.wetag = createETagGenerator({ weak: true })
*/

exports.normalizeType = function(type){
return ~type.indexOf('/')
return type.includes('/')
? acceptParams(type)
: { value: (mime.lookup(type) || 'application/octet-stream'), params: {} }
};
Expand Down Expand Up @@ -108,7 +108,7 @@ function acceptParams (str) {
var value = str.slice(splitIndex + 1, endIndex).trim();

if (key === 'q') {
ret.quality = parseFloat(value);
ret.quality = parseInt(value, 10);
} else {
ret.params[key] = value;
}
Expand All @@ -135,12 +135,12 @@ exports.compileETag = function(val) {
}

switch (val) {
case true:
case 'weak':
fn = exports.wetag;
break;
case false:
break;
case true:
case 'strong':
fn = exports.etag;
break;
Expand Down Expand Up @@ -201,7 +201,7 @@ exports.compileTrust = function(val) {

if (typeof val === 'number') {
// Support trusting hop count
return function(a, i){ return i < val };
return function(a, i){ return i <= val };
}

if (typeof val === 'string') {
Expand Down