summaryrefslogtreecommitdiffstats
path: root/model
diff options
context:
space:
mode:
Diffstat (limited to 'model')
-rw-r--r--model/search_params.go4
-rw-r--r--model/search_params_test.go4
-rw-r--r--model/utils.go1
3 files changed, 7 insertions, 2 deletions
diff --git a/model/search_params.go b/model/search_params.go
index 9a7406a07..d31782691 100644
--- a/model/search_params.go
+++ b/model/search_params.go
@@ -89,9 +89,9 @@ func parseSearchFlags(input []string) ([]string, [][2]string) {
}
if !isFlag {
- // trim off surrounding punctuation
+ // trim off surrounding punctuation (note that we leave trailing asterisks to allow wildcards)
word = puncStart.ReplaceAllString(word, "")
- word = puncEnd.ReplaceAllString(word, "")
+ word = puncEndWildcard.ReplaceAllString(word, "")
// and remove extra pound #s
word = hashtagStart.ReplaceAllString(word, "#")
diff --git a/model/search_params_test.go b/model/search_params_test.go
index 59eb0a113..7138d82c4 100644
--- a/model/search_params_test.go
+++ b/model/search_params_test.go
@@ -216,4 +216,8 @@ func TestParseSearchParams(t *testing.T) {
if sp := ParseSearchParams("##hashtag +#plus+"); len(sp) != 1 || sp[0].Terms != "#hashtag #plus" || sp[0].IsHashtag != true || len(sp[0].InChannels) != 0 || len(sp[0].FromUsers) != 0 {
t.Fatalf("Incorrect output from parse search params: %v", sp[0])
}
+
+ if sp := ParseSearchParams("wildcar*"); len(sp) != 1 || sp[0].Terms != "wildcar*" || sp[0].IsHashtag != false || len(sp[0].InChannels) != 0 || len(sp[0].FromUsers) != 0 {
+ t.Fatalf("Incorrect output from parse search params: %v", sp[0])
+ }
}
diff --git a/model/utils.go b/model/utils.go
index 695d4a0cb..808c89e30 100644
--- a/model/utils.go
+++ b/model/utils.go
@@ -291,6 +291,7 @@ var validHashtag = regexp.MustCompile(`^(#[A-Za-zäöüÄÖÜß]+[A-Za-z0-9äöÃ
var puncStart = regexp.MustCompile(`^[.,()&$!\?\[\]{}':;\\<>\-+=%^*|]+`)
var hashtagStart = regexp.MustCompile(`^#{2,}`)
var puncEnd = regexp.MustCompile(`[.,()&$#!\?\[\]{}':;\\<>\-+=%^*|]+$`)
+var puncEndWildcard = regexp.MustCompile(`[.,()&$#!\?\[\]{}':;\\<>\-+=%^|]+$`)
func ParseHashtags(text string) (string, string) {
words := strings.Fields(text)