mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-21 04:53:58 +08:00
fix(config): using sessionStorage is not safe
This commit is contained in:
@ -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() {
|
||||
|
Reference in New Issue
Block a user