Skip to content

Commit

Permalink
Add prefix to local storage keys
Browse files Browse the repository at this point in the history
This is so we don't clutter localStorage keyspace when hosting
multiple apps
  • Loading branch information
Property404 committed Aug 26, 2020
1 parent a7e0151 commit 8484672
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Settings.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import {getExample} from "./examples.js";
const LOCAL_STORAGE_PREFIX = "brainfuck_debugger_app__";
// let's still be functional even if storage is disabled
let fauxStorage={};
export function putLocalStorage(key, value)
{
try{
localStorage[key] = value;
localStorage[LOCAL_STORAGE_PREFIX+key] = value;
}catch(e){
fauxStorage[key] = value;
}
Expand All @@ -13,7 +14,7 @@ export function accessLocalStorage(key)
{
let val;
try{
val = localStorage[key];
val = localStorage[LOCAL_STORAGE_PREFIX+key];
}catch(e){
val = fauxStorage[key];
}
Expand Down

0 comments on commit 8484672

Please sign in to comment.