mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2024-11-23 15:47:53 -05:00
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:
commit
5976c566cf
1 changed files with 5 additions and 1 deletions
|
@ -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 = {
|
||||||
// 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) {
|
||||||
|
|
Loading…
Reference in a new issue