diff --git a/.vscode/settings.json b/.vscode/settings.json index 3047195..1a0e0dd 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,8 +1,8 @@ { "typescript.tsdk": "node_modules/typescript/lib", "editor.codeActionsOnSave": { - "source.fixAll": true, - "source.fixAll.markdownlint": true + "source.fixAll": "explicit", + "source.fixAll.markdownlint": "explicit" }, "svelte.plugin.svelte.format.config.singleQuote": true, "[svelte]": { diff --git a/src/persisted/storage-utils.ts b/src/persisted/storage-utils.ts index 455d2a7..92c718d 100644 --- a/src/persisted/storage-utils.ts +++ b/src/persisted/storage-utils.ts @@ -4,7 +4,19 @@ const cookieStorage = new CookieStorage(); export const getLocalStorageItem = (key: string): unknown => { const item = window.localStorage.getItem(key); - return item ? JSON.parse(item) : null; + let value + + if (item) { + try { + value = JSON.parse(item); + } catch { + value = item + } + } else { + value = null + } + + return value; }; export const setLocalStorageItem = (key: string, value: unknown): void => {