Skip to content

Commit

Permalink
Merge pull request #22 from victorquinn/master
Browse files Browse the repository at this point in the history
Fix bug causing crash if localStorage not available
  • Loading branch information
tsironis committed Dec 9, 2015
2 parents 428a752 + 514832f commit 4e9af2d
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions lockr.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,15 @@
try {
value = JSON.parse(localStorage.getItem(query_key));
} catch (e) {
if( localStorage[query_key] ){
value = JSON.parse('{"data":"' + localStorage.getItem(query_key) + '"}')
}else{
value = null;
}
try {
if(localStorage[query_key]) {
value = JSON.parse('{"data":"' + localStorage.getItem(query_key) + '"}');
} else{
value = null;
}
} catch (e) {
if (console) console.warn("Lockr could not load the item with key " + key);
}
}
if(value === null) {
return missing;
Expand Down

0 comments on commit 4e9af2d

Please sign in to comment.