Merge pull request #640 from mewtaylor/issue/gh-626-empty-banner

Fix GH-626: Set null contents to null instead of error throw
This commit is contained in:
Matthew Taylor 2016-06-30 13:19:19 -04:00 committed by GitHub
commit 5976c566cf

View file

@ -15,7 +15,8 @@ var Jar = {
// Return the usable content portion of a signed, compressed cookie generated by
// Django's signing module
// https://github.com/django/django/blob/stable/1.8.x/django/core/signing.py
if (!value) return callback('No value to unsign');
if (typeof value === 'undefined') return callback(null, value);
try {
var b64Data = value.split(':')[0];
var decompress = false;
@ -78,8 +79,11 @@ var Jar = {
// Get a value from a signed object
Jar.get(cookieName, function (err, value) {
if (err) return callback(err);
if (typeof value === 'undefined') return callback(null, value);
Jar.unsign(value, function (err, contents) {
if (err) return callback(err);
try {
var data = JSON.parse(contents);
} catch (err) {