We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents ea5509f + 37ceae3 commit 2f43074Copy full SHA for 2f43074
src/lib/storage.ts
@@ -16,7 +16,7 @@ class FallbackStorage {
16
valid: boolean = checkLocalStorage();
17
18
setItem(key: string, value: any) {
19
- const string = JSON.stringify(value);
+ const string = typeof value === 'string' ? value : JSON.stringify(value);
20
if (this.valid) {
21
localStorage.setItem(key, string);
22
return;
@@ -28,11 +28,12 @@ class FallbackStorage {
28
let value = this.valid
29
? localStorage.getItem(key)
30
: this.fallbackStorage[key];
31
+ if (!value) return null;
32
try {
33
const parsed = JSON.parse(value || '');
34
return parsed;
35
} catch (e) {
- return null;
36
+ return value || null;
37
}
38
39
0 commit comments