Skip to content

Commit 186e938

Browse files
committed
Enhance detection of PV key validity in localStorage
1 parent e9b3036 commit 186e938

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

assets/js/_utils/pageviews.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,20 @@ const PvStorage = (function () {
7575
return PvStorage.getAllPageviews() > pv.totalsForAllResults["ga:pageviews"];
7676
},
7777
inspectKeys() {
78-
if (localStorage.getItem(KEY_PV) === null
79-
|| localStorage.getItem(KEY_CREATION) === null) {
80-
localStorage.clear();
78+
for(let i = 0; i < localStorage.length; i++){
79+
const key = localStorage.key(i);
80+
switch (key) {
81+
case KEY_PV:
82+
case KEY_CREATION:
83+
break;
84+
default:
85+
localStorage.clear();
86+
return;
87+
}
8188
}
8289
}
8390
};
84-
85-
}()); /* PvData */
91+
}()); /* PvStorage */
8692

8793
function countUp(min, max, destId) {
8894
if (min < max) {

assets/js/dist/pvreport.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)