fix: gracefully ignore bad JSON in localstorage (#385)
Don't crash (catch the exception) if the localstorage value does not contain valid JSON.release
parent
edcd64b101
commit
f3387cdce2
|
@ -44,13 +44,13 @@ function get(key) {
|
||||||
if (!isLocalStorageSupported) return
|
if (!isLocalStorageSupported) return
|
||||||
try {
|
try {
|
||||||
var value = window.localStorage[`${NAMESPACE}.${key}`]
|
var value = window.localStorage[`${NAMESPACE}.${key}`]
|
||||||
} catch (e) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if (value) {
|
if (value) {
|
||||||
return JSON.parse(value)
|
return JSON.parse(value)
|
||||||
}
|
}
|
||||||
|
} catch (e) {
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue