You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Lets say I have my localstorage entries prefixed with dd82-app, and I want to clear all keys with that prefix. I do this with localStorageService.clearAll('^' + this._constants.prefix + '.');
This call always returns true, although the keys and values still exist in localstorage. Digging through the code reveals the issue at line 305:
// Only remove items that are for this app and match the regular expression
if (prefixRegex.test(key) && testRegex.test(key.substr(prefixLength))) {
So, with my prefix dd82-app, results in a prefixRegex value of /^dd82-app./ and testRegex matching
So, for a sample key dd82-app.access_token, the first part of the conditional, prefixRegex.test(key) works. It fails on the second part, because key.substr(prefixLength) returns a value of access-token, which does not match testRegex. Because that conditonal fails, the key is never removed.
In my case, this can be fixed by adding 0, resulting in a key.substr(0, prefixLength) call, but may break other cases.
The text was updated successfully, but these errors were encountered:
Lets say I have my localstorage entries prefixed with
dd82-app
, and I want to clear all keys with that prefix. I do this withlocalStorageService.clearAll('^' + this._constants.prefix + '.');
This call always returns true, although the keys and values still exist in localstorage. Digging through the code reveals the issue at line 305:
So, with my prefix
dd82-app
, results in aprefixRegex
value of/^dd82-app./
andtestRegex
matchingSo, for a sample key
dd82-app.access_token
, the first part of the conditional,prefixRegex.test(key)
works. It fails on the second part, becausekey.substr(prefixLength)
returns a value ofaccess-token
, which does not matchtestRegex
. Because that conditonal fails, the key is never removed.In my case, this can be fixed by adding 0, resulting in a
key.substr(0, prefixLength)
call, but may break other cases.The text was updated successfully, but these errors were encountered: