yusuketk 7 лет назад
Родитель
Сommit
30b3dcaad3
1 измененных файлов с 9 добавлено и 5 удалено
  1. 9 5
      src/server/util/search.js

+ 9 - 5
src/server/util/search.js

@@ -689,6 +689,7 @@ SearchClient.prototype.parseQueryString = function(queryString) {
   const prefixPaths = [];
   const prefixPaths = [];
   const notPrefixPaths = [];
   const notPrefixPaths = [];
   const tags = [];
   const tags = [];
+  const notTags = [];
 
 
   queryString.trim();
   queryString.trim();
   queryString = queryString.replace(/\s+/g, ' '); // eslint-disable-line no-param-reassign
   queryString = queryString.replace(/\s+/g, ' '); // eslint-disable-line no-param-reassign
@@ -717,16 +718,18 @@ SearchClient.prototype.parseQueryString = function(queryString) {
       return;
       return;
     }
     }
 
 
-    // https://regex101.com/r/lN4LIV/1
-    const matchNegative = word.match(/^-(prefix:)?(.+)$/);
-    // https://regex101.com/r/gVssZe/2
+    // https://regex101.com/r/pN9XfK/1
+    const matchNegative = word.match(/^-(prefix:|tag:)?(.+)$/);
+    // https://regex101.com/r/fP9ohQ/1
     const matchPositive = word.match(/^(prefix:|tag:)?(.+)$/);
     const matchPositive = word.match(/^(prefix:|tag:)?(.+)$/);
 
 
     if (matchNegative != null) {
     if (matchNegative != null) {
-      const isPrefixCondition = (matchNegative[1] != null);
-      if (isPrefixCondition) {
+      if (matchNegative[1] === 'prefix:') {
         notPrefixPaths.push(matchNegative[2]);
         notPrefixPaths.push(matchNegative[2]);
       }
       }
+      else if (matchNegative[1] === 'tag:') {
+        notTags.push(matchNegative[2]);
+      }
       else {
       else {
         notMatchWords.push(matchNegative[2]);
         notMatchWords.push(matchNegative[2]);
       }
       }
@@ -752,6 +755,7 @@ SearchClient.prototype.parseQueryString = function(queryString) {
     prefix: prefixPaths,
     prefix: prefixPaths,
     not_prefix: notPrefixPaths,
     not_prefix: notPrefixPaths,
     tag: tags,
     tag: tags,
+    not_tag: notTags,
   };
   };
 };
 };