Stopped removing *s from the end of search phrases
Этот коммит содержится в:
@@ -89,9 +89,9 @@ func parseSearchFlags(input []string) ([]string, [][2]string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if !isFlag {
|
if !isFlag {
|
||||||
// trim off surrounding punctuation
|
// trim off surrounding punctuation (note that we leave trailing asterisks to allow wildcards)
|
||||||
word = puncStart.ReplaceAllString(word, "")
|
word = puncStart.ReplaceAllString(word, "")
|
||||||
word = puncEnd.ReplaceAllString(word, "")
|
word = puncEndWildcard.ReplaceAllString(word, "")
|
||||||
|
|
||||||
// and remove extra pound #s
|
// and remove extra pound #s
|
||||||
word = hashtagStart.ReplaceAllString(word, "#")
|
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 {
|
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])
|
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 puncStart = regexp.MustCompile(`^[.,()&$!\?\[\]{}':;\\<>\-+=%^*|]+`)
|
||||||
var hashtagStart = regexp.MustCompile(`^#{2,}`)
|
var hashtagStart = regexp.MustCompile(`^#{2,}`)
|
||||||
var puncEnd = regexp.MustCompile(`[.,()&$#!\?\[\]{}':;\\<>\-+=%^*|]+$`)
|
var puncEnd = regexp.MustCompile(`[.,()&$#!\?\[\]{}':;\\<>\-+=%^*|]+$`)
|
||||||
|
var puncEndWildcard = regexp.MustCompile(`[.,()&$#!\?\[\]{}':;\\<>\-+=%^|]+$`)
|
||||||
|
|
||||||
func ParseHashtags(text string) (string, string) {
|
func ParseHashtags(text string) (string, string) {
|
||||||
words := strings.Fields(text)
|
words := strings.Fields(text)
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user