Skip to content

Commit

Permalink
Ensure non-available localStorage fails gracefully (polkadot-js#6837)
Browse files Browse the repository at this point in the history
  • Loading branch information
jacogr authored Jan 17, 2022
1 parent 919c559 commit 8bcd0e8
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/apps-config/src/endpoints/development.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[];
Expand Down

0 comments on commit 8bcd0e8

Please sign in to comment.