File tree Expand file tree Collapse file tree 2 files changed +31
-2
lines changed
Expand file tree Collapse file tree 2 files changed +31
-2
lines changed Original file line number Diff line number Diff line change @@ -13,13 +13,16 @@ import (
1313)
1414
1515func hasFilter (query , filterType string ) bool {
16- pattern := fmt .Sprintf (`(^|\s)%s:\S+` , regexp .QuoteMeta (filterType ))
16+ // Match filter at start of string, after whitespace, or after non-word characters like '('
17+ pattern := fmt .Sprintf (`(^|\s|\W)%s:\S+` , regexp .QuoteMeta (filterType ))
1718 matched , _ := regexp .MatchString (pattern , query )
1819 return matched
1920}
2021
2122func hasSpecificFilter (query , filterType , filterValue string ) bool {
22- pattern := fmt .Sprintf (`(^|\s)%s:%s($|\s)` , regexp .QuoteMeta (filterType ), regexp .QuoteMeta (filterValue ))
23+ // Match specific filter:value at start, after whitespace, or after non-word characters
24+ // End with word boundary, whitespace, or non-word characters like ')'
25+ pattern := fmt .Sprintf (`(^|\s|\W)%s:%s($|\s|\W)` , regexp .QuoteMeta (filterType ), regexp .QuoteMeta (filterValue ))
2326 matched , _ := regexp .MatchString (pattern , query )
2427 return matched
2528}
Original file line number Diff line number Diff line change @@ -91,6 +91,18 @@ func Test_hasFilter(t *testing.T) {
9191 filterType : "repo" ,
9292 expected : true ,
9393 },
94+ {
95+ name : "filter in parentheses at start" ,
96+ query : "(label:bug OR owner:bob) is:issue" ,
97+ filterType : "label" ,
98+ expected : true ,
99+ },
100+ {
101+ name : "filter after opening parenthesis" ,
102+ query : "is:issue (label:critical OR repo:test/test)" ,
103+ filterType : "label" ,
104+ expected : true ,
105+ },
94106 }
95107
96108 for _ , tt := range tests {
@@ -259,6 +271,20 @@ func Test_hasSpecificFilter(t *testing.T) {
259271 filterValue : "issue" ,
260272 expected : true ,
261273 },
274+ {
275+ name : "filter:value in parentheses at start" ,
276+ query : "(is:issue OR is:pr) label:bug" ,
277+ filterType : "is" ,
278+ filterValue : "issue" ,
279+ expected : true ,
280+ },
281+ {
282+ name : "filter:value after opening parenthesis" ,
283+ query : "repo:test/repo (is:issue AND label:bug)" ,
284+ filterType : "is" ,
285+ filterValue : "issue" ,
286+ expected : true ,
287+ },
262288 }
263289
264290 for _ , tt := range tests {
You can’t perform that action at this time.
0 commit comments