Commit 5976c566 authored by Matthew Taylor's avatar Matthew Taylor Committed by GitHub

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

Fix GH-626: Set null contents to null instead of error throw
parents 4ef6b22b 04aa7e01
...@@ -15,7 +15,8 @@ var Jar = { ...@@ -15,7 +15,8 @@ var Jar = {
// Return the usable content portion of a signed, compressed cookie generated by // Return the usable content portion of a signed, compressed cookie generated by
// Django's signing module // Django's signing module
// https://github.com/django/django/blob/stable/1.8.x/django/core/signing.py // 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 { try {
var b64Data = value.split(':')[0]; var b64Data = value.split(':')[0];
var decompress = false; var decompress = false;
...@@ -78,8 +79,11 @@ var Jar = { ...@@ -78,8 +79,11 @@ var Jar = {
// Get a value from a signed object // Get a value from a signed object
Jar.get(cookieName, function (err, value) { Jar.get(cookieName, function (err, value) {
if (err) return callback(err); if (err) return callback(err);
if (typeof value === 'undefined') return callback(null, value);
Jar.unsign(value, function (err, contents) { Jar.unsign(value, function (err, contents) {
if (err) return callback(err); if (err) return callback(err);
try { try {
var data = JSON.parse(contents); var data = JSON.parse(contents);
} catch (err) { } catch (err) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment