浏览代码

add collection name validation

tumao 4 年之前
父节点
当前提交
48bbd17cbc
共有 1 个文件被更改,包括 5 次插入1 次删除
  1. 5 1
      client/src/pages/seach/VectorSearch.tsx

+ 5 - 1
client/src/pages/seach/VectorSearch.tsx

@@ -194,7 +194,11 @@ const VectorSearch = () => {
   useEffect(() => {
     if (location.search && collections.length > 0) {
       const { collectionName } = parseLocationSearch(location.search);
-      setSelectedCollection(collectionName);
+      // collection name validation
+      const isNameValid = collections
+        .map(c => c._name)
+        .includes(collectionName);
+      isNameValid && setSelectedCollection(collectionName);
     }
   }, [location, collections]);