yusuketk hace 7 años
padre
commit
0026cd9a51
Se han modificado 1 ficheros con 9 adiciones y 5 borrados
  1. 9 5
      src/server/util/search.js

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

@@ -719,8 +719,10 @@ SearchClient.prototype.parseQueryString = function(queryString) {
 
     // https://regex101.com/r/lN4LIV/1
     const matchNegative = word.match(/^-(prefix:)?(.+)$/);
-    // https://regex101.com/r/gVssZe/2
-    const matchPositive = word.match(/^(prefix:|tag:)?(.+)$/);
+    // https://regex101.com/r/gVssZe/1
+    const matchPositive = word.match(/^(prefix:)?(.+)$/);
+    // https://regex101.com/r/cPbWPw/1
+    const matchTag = word.match(/^(tag:)?(.+)$/);
 
     if (matchNegative != null) {
       const isPrefixCondition = (matchNegative[1] != null);
@@ -732,11 +734,13 @@ SearchClient.prototype.parseQueryString = function(queryString) {
       }
     }
     else if (matchPositive != null) {
-      if (matchPositive[1] === 'prefix:') {
+      const isPrefixCondition = (matchPositive[1] != null);
+      const isTagCondition = (matchTag[1] != null);
+      if (isPrefixCondition) {
         prefixPaths.push(matchPositive[2]);
       }
-      else if (matchPositive[1] === 'tag:') {
-        tags.push(matchPositive[2]);
+      else if (isTagCondition) {
+        tags.push(matchTag[2]);
       }
       else {
         matchWords.push(matchPositive[2]);