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
|
||||
try {
|
||||
var value = window.localStorage[`${NAMESPACE}.${key}`]
|
||||
} catch (e) {
|
||||
return
|
||||
}
|
||||
|
||||
if (value) {
|
||||
return JSON.parse(value)
|
||||
}
|
||||
} catch (e) {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue