fix JSON.parse(null)

if window.localStorage.config is null then JSON.parse returns an error about "u" not being valid (the word "undefined" is not valid JSON apparently :). So I test for null-ness first.
This commit is contained in:
Chris Wiegand 2014-06-03 21:55:16 -06:00
parent 896e90c1ee
commit 47cf9b6980

View File

@ -17,7 +17,8 @@ function LocalStorage() {
* if config is null the default config will be used
*/
LocalStorage.prototype.read = function () {
var cf = JSON.parse(window.localStorage.getItem("config"));
var raw = window.localStorage.getItem("config");
var cf = (raw === null ? null : JSON.parse(raw));
if (cf === null) {
this.config = this.default_config;
this.write();