diff options
author | Joram Wilander <jwawilander@gmail.com> | 2016-03-07 07:47:51 -0500 |
---|---|---|
committer | Joram Wilander <jwawilander@gmail.com> | 2016-03-07 07:47:51 -0500 |
commit | e9c94bf27c0a4223c5fde0ba85155412c25d94f3 (patch) | |
tree | 2f9226a2eae086072b91cab1dda564db3fb04019 /model | |
parent | 81ccfca2bfc91779d7bf00dbccb6f932d285a87c (diff) | |
parent | cd4172bfd8d60b655bb0294b5dfc6f13e897b807 (diff) | |
download | chat-e9c94bf27c0a4223c5fde0ba85155412c25d94f3.tar.gz chat-e9c94bf27c0a4223c5fde0ba85155412c25d94f3.tar.bz2 chat-e9c94bf27c0a4223c5fde0ba85155412c25d94f3.zip |
Merge pull request #2332 from hmhealey/plt2014
PLT-2014 Stopped removing *s from the end of search phrases
Diffstat (limited to 'model')
-rw-r--r-- | model/search_params.go | 4 | ||||
-rw-r--r-- | model/search_params_test.go | 4 | ||||
-rw-r--r-- | model/utils.go | 1 |
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) |