Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

delete unused variables, delete duplicate declaration #691

Merged
merged 1 commit into from

4 participants

@Laboratory

No description provided.

@tj tj merged commit 6f411e5 into senchalabs:master
@tj tj commented on the diff
lib/middleware/directory.js
@@ -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);
@tj Owner
tj added a note

this is the only part i still prefer, i dont care much for the linters

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@shesek

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

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

Owner

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

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

Owner

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

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

Owner

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
This page is out of date. Refresh to see the latest.
View
1  .gitignore
@@ -14,3 +14,4 @@ test.js
docs/*.html
docs/*.json
node_modules
+.idea
View
2  lib/middleware/basicAuth.js
@@ -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));
View
6 lib/middleware/compress.js
@@ -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();
};
-}
+};
View
3  lib/middleware/cookieParser.js
@@ -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) {
View
8 lib/middleware/cookieSession.js
@@ -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) {
View
4 lib/middleware/csrf.js
@@ -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
View
4 lib/middleware/directory.js
@@ -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);
@tj Owner
tj added a note

this is the only part i still prefer, i dont care much for the linters

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
return function directory(req, res, next) {
if ('GET' != req.method && 'HEAD' != req.method) return next();
View
2  lib/middleware/errorHandler.js
@@ -42,7 +42,7 @@ var env = process.env.NODE_ENV || 'development';
*/
exports = module.exports = function errorHandler(){
- return function errorHandler(err, req, res, next){
+ 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);
View
4 lib/middleware/json.js
@@ -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)
View
6 lib/middleware/session.js
@@ -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) {
View
3  lib/middleware/session/store.js
@@ -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;
View
2  lib/middleware/static.js
@@ -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();
View
2  lib/middleware/staticCache.js
@@ -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;
View
2  lib/utils.js
@@ -232,7 +232,7 @@ exports.parseJSONCookie = function(str) {
// no op
}
}
-}
+};
/**
* Pause `data` and `end` events on the given `obj`.
Something went wrong with that request. Please try again.