From d16bbdd1d9aa29abd846f244523af94dec859907 Mon Sep 17 00:00:00 2001 From: Adrian Andersen Date: Fri, 23 Aug 2024 13:38:01 +0200 Subject: [PATCH] fix(storage): try/catch localStorage.get --- src/api/storage.ts | 6 +++++- yarn.lock | 13 ++++--------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/api/storage.ts b/src/api/storage.ts index 832ecec..05f5576 100644 --- a/src/api/storage.ts +++ b/src/api/storage.ts @@ -4,7 +4,11 @@ export const add = (key: string, value: string): boolean => { }; export const get = (key: string): string | null => { - return localStorage.getItem(key); + try { + return localStorage.getItem(key); + } catch { + return null; + } }; export const remove = (key: string): boolean => { diff --git a/yarn.lock b/yarn.lock index 90be8a5..3396f83 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1625,15 +1625,10 @@ callsites@^3.0.0: resolved "https://registry.yarnpkg.com/callsites/-/callsites-3.1.0.tgz#b3630abd8943432f54b3f0519238e33cd7df2f73" integrity sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ== -caniuse-lite@^1.0.30001579: - version "1.0.30001587" - resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001587.tgz#a0bce920155fa56a1885a69c74e1163fc34b4881" - integrity sha512-HMFNotUmLXn71BQxg8cijvqxnIAofforZOwGsxyXJ0qugTdspUF4sPSJ2vhgprHCB996tIDzEq1ubumPDV8ULA== - -caniuse-lite@^1.0.30001629: - version "1.0.30001639" - resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001639.tgz#972b3a6adeacdd8f46af5fc7f771e9639f6c1521" - integrity sha512-eFHflNTBIlFwP2AIKaYuBQN/apnUoKNhBdza8ZnW/h2di4LCZ4xFqYlxUxo+LQ76KFI1PGcC1QDxMbxTZpSCAg== +caniuse-lite@^1.0.30001579, caniuse-lite@^1.0.30001629: + version "1.0.30001651" + resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001651.tgz" + integrity sha512-9Cf+Xv1jJNe1xPZLGuUXLNkE1BoDkqRqYyFJ9TDYSqhduqA4hu4oR9HluGoWYQC/aj8WHjsGVV+bwkh0+tegRg== caseless@~0.12.0: version "0.12.0"