mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
Stopped removing *s from the end of search phrases
This commit is contained in:
@@ -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, "#")
|
||||
|
||||
@@ -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])
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user