Skip to content

Commit a9527be

Browse files
committed
strip prefix when getting all keys
1 parent ad62b75 commit a9527be

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

‎src/WebStorageStateStore.js‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,15 @@ export default class WebStorageStateStore {
3939
}
4040

4141
getAllKeys() {
42+
Log.info("WebStorageStateStore.getAllKeys");
43+
4244
var keys = [];
4345

4446
for (let index = 0; index < this._store.length; index++) {
4547
let key = this._store.key(index);
4648

4749
if (key.indexOf(this._prefix) === 0) {
48-
keys.push(key);
50+
keys.push(key.substr(this._prefix.length));
4951
}
5052
}
5153

‎test/unit/WebStorageStateStore.spec.js‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,19 @@ describe("WebStorageStateStore", function() {
140140
});
141141
});
142142

143+
it("should return keys without prefix", function(done) {
144+
prefix = "foo.";
145+
subject = new WebStorageStateStore({ prefix: prefix, store: store });
146+
147+
store.setItem("foo.key1", "test");
148+
store.setItem("foo.key2", "test");
149+
150+
subject.getAllKeys().then(keys => {
151+
keys.should.deep.equal(["key1", "key2"]);
152+
done();
153+
});
154+
});
155+
143156
it("should return empty keys when empty", function(done) {
144157
subject.getAllKeys().then(keys => {
145158
keys.should.deep.equal([]);

0 commit comments

Comments
 (0)