Ensure non-available localStorage fails gracefully (#6837)
This commit is contained in:
parent
919c559ad7
commit
8bcd0e8d30
@ -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[];
|
||||
|
||||
Loading…
Reference in New Issue
Block a user