From 664f4c3ce9180db351ca32ad4ef731246cd9f314 Mon Sep 17 00:00:00 2001 From: Matt Gibson Date: Wed, 12 Mar 2025 10:53:31 -0700 Subject: [PATCH] Fix collection searching Collection searching is wildcarded by default to avoid having to type perfectly --- libs/common/src/vault/search/parse.ts | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/libs/common/src/vault/search/parse.ts b/libs/common/src/vault/search/parse.ts index c2200c78bdd..42a7ff04a2f 100644 --- a/libs/common/src/vault/search/parse.ts +++ b/libs/common/src/vault/search/parse.ts @@ -220,20 +220,20 @@ function handleNode(node: AstNode): ProcessInstructions { ], }; } else if (isInCollection(node)) { - // TODO: There is currently no collection name information in a cipher view + const collectionTest = termToRegexTest(node.collection); return { filter: (context) => { - const collectionId = context.collections.find( - (collection) => collection.name === node.collection, - )?.id; + const collectionIds = context.collections + .filter( + (collection) => + collectionTest.test(collection.name) || collectionTest.test(collection.id), + ) + .map((collection) => collection.id); return { ...context, - ciphers: - collectionId == null - ? // Collection not found, no matches - // TODO: should this be an error? - [] - : context.ciphers.filter((cipher) => cipher.collectionIds.includes(collectionId)), + ciphers: context.ciphers.filter((cipher) => + collectionIds.some((collectionId) => cipher.collectionIds.includes(collectionId)), + ), }; }, sections: [