Skip to content

Commit

Permalink
fix(config): using sessionStorage is not safe
Browse files Browse the repository at this point in the history
  • Loading branch information
manucorporat committed Aug 22, 2018
1 parent 88613ff commit 091b433
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions core/src/utils/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,20 @@ const IONIC_PREFIX = 'ionic:';
const IONIC_SESSION_KEY = 'ionic-persist-config';

export function configFromSession(): any {
const configStr = window.sessionStorage.getItem(IONIC_SESSION_KEY);
return configStr ? JSON.parse(configStr) : {};
try {
const configStr = window.sessionStorage.getItem(IONIC_SESSION_KEY);
return configStr ? JSON.parse(configStr) : {};
} catch {
return {};
}
}

export function saveConfig(config: any) {
window.sessionStorage.setItem(IONIC_SESSION_KEY, JSON.stringify(config));
try {
window.sessionStorage.setItem(IONIC_SESSION_KEY, JSON.stringify(config));
} catch {
return;
}
}

export function configFromURL() {
Expand Down

0 comments on commit 091b433

Please sign in to comment.