[Pkg-javascript-commits] [node-mocks-http] 226/296: Fix lint errors
Thorsten Alteholz
alteholz at moszumanska.debian.org
Mon Feb 8 18:13:39 UTC 2016
This is an automated email from the git hooks/post-receive script.
alteholz pushed a commit to branch master
in repository node-mocks-http.
commit 7103d5319a13d9e0565c22786c17634b35050593
Author: Johnny Estilles <johnny.estilles at agentia.asia>
Date: Sat May 23 13:10:59 2015 +0800
Fix lint errors
---
lib/mock-request.js | 42 +++++++++++++++++++++++-------------------
1 file changed, 23 insertions(+), 19 deletions(-)
diff --git a/lib/mock-request.js b/lib/mock-request.js
index 5060ef4..ca03039 100644
--- a/lib/mock-request.js
+++ b/lib/mock-request.js
@@ -4,6 +4,8 @@ var accepts = require('accepts');
var typeis = require('type-is');
var parseRange = require('range-parser');
var parse = require('parseurl');
+var isIP = require('net').isIP;
+var fresh = require('fresh');
var http = require('./node/http');
@@ -51,7 +53,9 @@ req.acceptsLanguage = req.acceptsLanguages;
req.range = function(size){
var range = this.get('Range');
- if (!range) return;
+ if (!range) {
+ return;
+ }
return parseRange(size, range);
};
@@ -60,16 +64,14 @@ req.param = function param(name, defaultValue) {
var body = this.body || {};
var query = this.query || {};
- var args = arguments.length === 1 ? 'name' : 'name, default';
-
- if (null != params[name] && params.hasOwnProperty(name)) {
- return params[name];
+ if (params[name] !== null && params.hasOwnProperty(name)) {
+ return params[name];
}
- if (null != body[name]) {
- return body[name];
+ if (body[name] !== null) {
+ return body[name];
}
- if (null != query[name]) {
- return query[name];
+ if (query[name] !== null) {
+ return query[name];
}
return defaultValue;
@@ -77,7 +79,7 @@ req.param = function param(name, defaultValue) {
req.is = function(types) {
if (!Array.isArray(types)) {
- types = [].slice.call(arguments);
+ types = [].slice.call(arguments);
}
return typeis(this, types);
};
@@ -89,7 +91,7 @@ defineGetter(req, 'protocol', function protocol() {
});
defineGetter(req, 'secure', function secure(){
- return 'https' == this.protocol;
+ return this.protocol === 'https';
});
defineGetter(req, 'ip', function ip(){
@@ -99,12 +101,14 @@ defineGetter(req, 'ip', function ip(){
defineGetter(req, 'subdomains', function subdomains() {
var hostname = this.hostname;
- if (!hostname) return [];
+ if (!hostname) {
+ return [];
+ }
var offset = this.app.get('subdomain offset');
- var subdomains = !isIP(hostname) ? hostname.split('.').reverse() : [hostname];
+ var domains = !isIP(hostname) ? hostname.split('.').reverse() : [hostname];
- return subdomains.slice(offset);
+ return domains.slice(offset);
});
defineGetter(req, 'path', function path() {
@@ -119,7 +123,7 @@ defineGetter(req, 'hostname', function hostname() {
}
if (!host) {
- return;
+ return;
}
var offset = host[0] === '[' ? host.indexOf(']') + 1 : 0;
@@ -136,11 +140,11 @@ defineGetter(req, 'fresh', function(){
var method = this.method;
var statusCode = this.res.statusCode;
- if ('GET' !== method && 'HEAD' !== method) {
- return false;
+ if (method !== 'GET' && method !== 'HEAD') {
+ return false;
}
- if ((statusCode >= 200 && statusCode < 300) || 304 === statusCode) {
+ if ((statusCode >= 200 && statusCode < 300) || statusCode === 304) {
return fresh(this.headers, (this.res._headers || {}));
}
@@ -162,4 +166,4 @@ function defineGetter(obj, name, getter) {
enumerable: true,
get: getter
});
-};
+}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-mocks-http.git
More information about the Pkg-javascript-commits
mailing list