From 8bcd0e8d30ac73076be92fd2ea81b133f1cf2ccc Mon Sep 17 00:00:00 2001 From: Jaco Date: Mon, 17 Jan 2022 09:28:21 +0100 Subject: [PATCH] Ensure non-available localStorage fails gracefully (#6837) --- packages/apps-config/src/endpoints/development.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/apps-config/src/endpoints/development.ts b/packages/apps-config/src/endpoints/development.ts index f5a3f685d2..812d3c4f57 100644 --- a/packages/apps-config/src/endpoints/development.ts +++ b/packages/apps-config/src/endpoints/development.ts @@ -40,7 +40,9 @@ export function createCustom (t: TFunction): LinkOption[] { export function createOwn (t: TFunction): LinkOption[] { try { // this may not be available, e.g. when running via script - const storedItems = localStorage?.getItem(CUSTOM_ENDPOINT_KEY); + const storedItems = typeof localStorage === 'object' && typeof localStorage.getItem === 'function' + ? localStorage.getItem(CUSTOM_ENDPOINT_KEY) + : null; if (storedItems) { const items = JSON.parse(storedItems) as string[];