Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

delete unused variables, delete duplicate declaration, added some sem…

…icolons
  • Loading branch information...
commit 82bf325adca699bed5a4f6226b4faefc8ca87372 1 parent 9fe77f4
Vitaly Laboratory authored
1  .gitignore
View
@@ -14,3 +14,4 @@ test.js
docs/*.html
docs/*.json
node_modules
+.idea
2  lib/middleware/basicAuth.js
View
@@ -67,7 +67,7 @@ module.exports = function basicAuth(callback, realm) {
if (req.user) return next();
if (!authorization) return unauthorized(res, realm);
- var parts = authorization.split(' ')
+ var parts = authorization.split(' ');
if (parts.length !== 2) return next(utils.error(400));
6 lib/middleware/compress.js
View
@@ -59,8 +59,8 @@ exports.filter = function(req, res){
*/
module.exports = function compress(options) {
- var options = options || {}
- , names = Object.keys(exports.methods)
+ options = options || {};
+ var names = Object.keys(exports.methods)
, filter = options.filter || exports.filter;
return function(req, res, next){
@@ -144,4 +144,4 @@ module.exports = function compress(options) {
next();
};
-}
+};
3  lib/middleware/cookieParser.js
View
@@ -49,8 +49,7 @@ module.exports = function cookieParser(secret){
req.cookies = cookie.parse(cookies);
if (secret) {
req.signedCookies = utils.parseSignedCookies(req.cookies, secret);
- var obj = utils.parseJSONCookies(req.signedCookies);
- req.signedCookies = obj;
+ req.signedCookies = utils.parseJSONCookies(req.signedCookies);
}
req.cookies = utils.parseJSONCookies(req.cookies);
} catch (err) {
8 lib/middleware/cookieSession.js
View
@@ -15,10 +15,6 @@ var utils = require('./../utils')
, signature = require('cookie-signature')
, crc16 = require('crc').crc16;
-// environment
-
-var env = process.env.NODE_ENV;
-
/**
* Cookie Session:
*
@@ -49,8 +45,8 @@ var env = process.env.NODE_ENV;
module.exports = function cookieSession(options){
// TODO: utilize Session/Cookie to unify API
- var options = options || {}
- , key = options.key || 'connect.sess'
+ options = options || {};
+ var key = options.key || 'connect.sess'
, trustProxy = options.proxy;
return function cookieSession(req, res, next) {
4 lib/middleware/csrf.js
View
@@ -37,8 +37,8 @@ var utils = require('../utils');
*/
module.exports = function csrf(options) {
- var options = options || {}
- , value = options.value || defaultValue;
+ options = options || {};
+ var value = options.value || defaultValue;
return function(req, res, next){
// generate CSRF token
4 lib/middleware/directory.js
View
@@ -52,8 +52,8 @@ exports = module.exports = function directory(root, options){
if (!root) throw new Error('directory() root path required');
var hidden = options.hidden
, icons = options.icons
- , filter = options.filter
- , root = normalize(root);
+ , filter = options.filter;
+ root = normalize(root);
return function directory(req, res, next) {
if ('GET' != req.method && 'HEAD' != req.method) return next();
2  lib/middleware/errorHandler.js
View
@@ -42,7 +42,7 @@ var env = process.env.NODE_ENV || 'development';
*/
exports = module.exports = function errorHandler(){
- return function errorHandler(err, req, res, next){
Nadav Ivgi
shesek added a note

Wouldn't it cause handle() to not properly identify it [1] as an error handler?

[1] https://github.com/senchalabs/connect/blob/master/lib/proto.js#L184

Douglas Christopher Wilson Owner

It did exactly that. Fixed in 8262bd3 it was probably removed because a linter said next was not used within the function's body.

TJ Holowaychuk Owner
tj added a note

yeah my bad, I force-published over this release, I didn't catch this initially

Douglas Christopher Wilson Owner

Thanks for the info about the force publish. I wasn't sure if I was going to see another dual release or not.

TJ Holowaychuk Owner
tj added a note

good old linters... haha pretending they know things and all

Sorry guys, I didn't see description about next and his usage in function...

TJ Holowaychuk Owner
tj added a note

no worries, I should have caught it on merge, someone let me know right away in #express anyway, not much damage done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ return function errorHandler(err, req, res){
if (err.status) res.statusCode = err.status;
if (res.statusCode < 400) res.statusCode = 500;
if ('test' != env) console.error(err.stack);
4 lib/middleware/json.js
View
@@ -40,9 +40,7 @@ function noop(req, res, next) {
exports = module.exports = function(options){
var options = options || {}
- , strict = options.strict === false
- ? false
- : true;
+ , strict = options.strict !== false;
var limit = options.limit
? _limit(options.limit)
6 lib/middleware/session.js
View
@@ -228,9 +228,7 @@ function session(options){
if (!secret) throw new Error('`secret` option required for sessions');
// parse url
- var url = parse(req)
- , path = url.pathname
- , originalHash
+ var originalHash
, originalId;
// expose store
@@ -310,7 +308,7 @@ function session(options){
next = function(err){
_next(err);
pause.resume();
- }
+ };
// error handling
if (err) {
3  lib/middleware/session/store.js
View
@@ -75,8 +75,7 @@ Store.prototype.load = function(sid, fn){
Store.prototype.createSession = function(req, sess){
var expires = sess.cookie.expires
- , orig = sess.cookie.originalMaxAge
- , update = null == update ? true : false;
+ , orig = sess.cookie.originalMaxAge;
sess.cookie = new Cookie(sess.cookie);
if ('string' == typeof expires) sess.cookie.expires = new Date(expires);
sess.cookie.originalMaxAge = orig;
2  lib/middleware/static.js
View
@@ -49,7 +49,7 @@ exports = module.exports = function static(root, options){
if (!root) throw new Error('static() root path required');
// default redirect
- var redirect = false === options.redirect ? false : true;
+ var redirect = false !== options.redirect;
return function static(req, res, next) {
if ('GET' != req.method && 'HEAD' != req.method) return next();
2  lib/middleware/staticCache.js
View
@@ -207,7 +207,7 @@ function mustRevalidate(req, cacheEntry) {
|| cacheCC['must-revalidate']
|| cacheCC['proxy-revalidate']) return true;
- if (reqCC['no-cache']) return true
+ if (reqCC['no-cache']) return true;
if (null != reqCC['max-age']) return reqCC['max-age'] < cacheAge;
2  lib/utils.js
View
@@ -232,7 +232,7 @@ exports.parseJSONCookie = function(str) {
// no op
}
}
-}
+};
/**
* Pause `data` and `end` events on the given `obj`.
Nadav Ivgi

Wouldn't it cause handle() to not properly identify it [1] as an error handler?

[1] https://github.com/senchalabs/connect/blob/master/lib/proto.js#L184

Douglas Christopher Wilson

It did exactly that. Fixed in 8262bd3 it was probably removed because a linter said next was not used within the function's body.

TJ Holowaychuk

yeah my bad, I force-published over this release, I didn't catch this initially

Douglas Christopher Wilson

Thanks for the info about the force publish. I wasn't sure if I was going to see another dual release or not.

TJ Holowaychuk

good old linters... haha pretending they know things and all

Vitaly

Sorry guys, I didn't see description about next and his usage in function...

TJ Holowaychuk

no worries, I should have caught it on merge, someone let me know right away in #express anyway, not much damage done

Please sign in to comment.
Something went wrong with that request. Please try again.