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
In this case key.indexOf(namespace) === 0 for namespace and namespacePersistent will be true and hence will reset both the namespaces.
Solution :
We can use a combination of namespace and delimiter for finding the index.
Considering the default delimiter as ' . ' a namespace delimiter combination will not return 0
let key = 'namespacePersistent.key1' ;
key.indexOf("namespace.") === 0 // false since index returned will be -1.
We can pass the namespace and delimiter combination from the callee.
reset: function (options) {
options = Basil.utils.extend({}, this.options, options);
Basil.utils.tryEach(_toStoragesArray(options.storages), function (storage) {
let namespaceStr = options.namespace+(options.keyDelimiter || '.');
_storages[storage].reset(namespaceStr);
}, null, this);
},
If this solution is looks fine I can raise a PR for the same.
The text was updated successfully, but these errors were encountered:
Thanks for this issue, very clear and even with envisaged solution :)
Indeed, we could easily replace key.indexOf(namespace) === 0 by key.indexOf(namespace + (options.keyDelimiter || '.' )) === 0 to ensure being more strict and make your case working.
Would you made making a PR with that change, and if possible, even with a test in the test suite (with your above example?)
Steps to reproduce -
I went through the code and observed that the way the "reset" function is implemented
In this case
key.indexOf(namespace) === 0
fornamespace
andnamespacePersistent
will betrue
and hence will reset both the namespaces.Solution :
We can use a combination of namespace and delimiter for finding the index.
Considering the default delimiter as ' . ' a namespace delimiter combination will not return 0
We can pass the namespace and delimiter combination from the callee.
If this solution is looks fine I can raise a PR for the same.
The text was updated successfully, but these errors were encountered: