diff options
author | Florian Dold <florian@dold.me> | 2022-08-24 21:07:09 +0200 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2022-08-24 21:07:13 +0200 |
commit | bf516a77e8d38e81ee9816d6ee0ab29bcb878e84 (patch) | |
tree | b055253881a4b59536b7ea68e40f36d5cd6fc888 /packages/idb-bridge/src/util | |
parent | fff3df81e447e43f7e3242af8944696225341156 (diff) | |
download | wallet-core-bf516a77e8d38e81ee9816d6ee0ab29bcb878e84.tar.xz |
fix idb bug, p2p integration test
Diffstat (limited to 'packages/idb-bridge/src/util')
-rw-r--r-- | packages/idb-bridge/src/util/extractKey.ts | 2 | ||||
-rw-r--r-- | packages/idb-bridge/src/util/getIndexKeys.test.ts | 4 | ||||
-rw-r--r-- | packages/idb-bridge/src/util/getIndexKeys.ts | 3 |
3 files changed, 5 insertions, 4 deletions
diff --git a/packages/idb-bridge/src/util/extractKey.ts b/packages/idb-bridge/src/util/extractKey.ts index b768ed92a..6a3d468ef 100644 --- a/packages/idb-bridge/src/util/extractKey.ts +++ b/packages/idb-bridge/src/util/extractKey.ts @@ -59,7 +59,7 @@ export const extractKey = (keyPath: IDBKeyPath | IDBKeyPath[], value: any) => { remainingKeyPath = null; } - if (!object.hasOwnProperty(identifier)) { + if (object == null || !object.hasOwnProperty(identifier)) { return; } diff --git a/packages/idb-bridge/src/util/getIndexKeys.test.ts b/packages/idb-bridge/src/util/getIndexKeys.test.ts index d3bbd519a..1d477de1a 100644 --- a/packages/idb-bridge/src/util/getIndexKeys.test.ts +++ b/packages/idb-bridge/src/util/getIndexKeys.test.ts @@ -26,9 +26,7 @@ test("basics", (t) => { t.deepEqual(getIndexKeys([1, 2, 3], "", false), [[1, 2, 3]]); - t.throws(() => { - getIndexKeys({ foo: 42 }, "foo.bar", false); - }); + t.deepEqual(getIndexKeys({ foo: 42 }, "foo.bar", false), []); t.deepEqual(getIndexKeys({ foo: 42 }, "foo", true), [42]); t.deepEqual( diff --git a/packages/idb-bridge/src/util/getIndexKeys.ts b/packages/idb-bridge/src/util/getIndexKeys.ts index 17e77e636..c2421f26e 100644 --- a/packages/idb-bridge/src/util/getIndexKeys.ts +++ b/packages/idb-bridge/src/util/getIndexKeys.ts @@ -38,6 +38,9 @@ export function getIndexKeys( return keys; } else if (typeof keyPath === "string" || Array.isArray(keyPath)) { let key = extractKey(keyPath, value); + if (key == null) { + return []; + } return [valueToKey(key)]; } else { throw Error(`unsupported key path: ${typeof keyPath}`); |