-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Complete package upgrades for node 7 compat
- Loading branch information
Showing
35 changed files
with
946 additions
and
2,787 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
{ | ||
"browser": true, | ||
"version": "es6", | ||
"camelcase": true, | ||
"curly": true, | ||
"devel": true, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
const onHeaders = require('on-headers'); | ||
const clone = require('lodash').cloneDeep; | ||
|
||
module.exports = function (blacklist) { | ||
if (blacklist && !Array.isArray(blacklist)) { | ||
blacklist = [blacklist]; | ||
} | ||
return function (req, res, next) { | ||
onHeaders(res, function () { | ||
res.locals._sessionBeforeBlacklist = clone(req.session); | ||
if (blacklist) { | ||
blacklist.forEach(key => deleteItem(req.session, key)); | ||
} | ||
}); | ||
next(); | ||
}; | ||
}; | ||
|
||
function deleteItem(object = {}, key) { | ||
const keys = key.split('.'); | ||
const last = keys.length - 1; | ||
return keys.reduce((obj, key, i) => { | ||
if (i === last && obj[key] !== undefined) { | ||
delete obj[key]; | ||
} | ||
return obj[key] || {}; | ||
}, object); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.