fixing global variable

revert-117-master
Matthew Wickman 11 years ago
parent 76d682a2da
commit b6e40ea795

@ -142,11 +142,11 @@ angularLocalStorage.service('localStorageService', [
// Should be used mostly for development purposes // Should be used mostly for development purposes
var clearAllFromLocalStorage = function (regular_expression) { var clearAllFromLocalStorage = function (regular_expression) {
regular_expression = regular_expression || ""; var regular_expression = regular_expression || "";
//accounting for the '.' in the prefix //accounting for the '.' in the prefix when creating a regex
var temp_prefix = prefix.slice(0, -1) + "\."; var temp_prefix = prefix.slice(0, -1) + "\.";
//regex to test the local storage keys against
var testregex = RegExp(temp_prefix + regular_expression); var testregex = RegExp(temp_prefix + regular_expression);
console.log('test regex: ', testregex);
if (!browserSupportsLocalStorage()) { if (!browserSupportsLocalStorage()) {
$rootScope.$broadcast('LocalStorageModule.notification.warning','LOCAL_STORAGE_NOT_SUPPORTED'); $rootScope.$broadcast('LocalStorageModule.notification.warning','LOCAL_STORAGE_NOT_SUPPORTED');
@ -157,10 +157,9 @@ angularLocalStorage.service('localStorageService', [
for (var key in localStorage) { for (var key in localStorage) {
// Only remove items that are for this app and match the regular expression // Only remove items that are for this app and match the regular expression
if (testregex.test(key)) { if (testregex.test(key)) {
try { try {
removeFromLocalStorage(key.substr(prefixLength)); removeFromLocalStorage(key.substr(prefixLength));
} catch (e) { } catch (e) {
$rootScope.$broadcast('LocalStorageModule.notification.error',e.message); $rootScope.$broadcast('LocalStorageModule.notification.error',e.message);
return clearAllFromCookies(); return clearAllFromCookies();