PLT-2283 Improved trimming of punctuation from hashtags and search terms (#3178)

* Improved trimming of punctuation from hashtags and search terms

* Separated punctuation regexes used for hashtags and for search terms
Этот коммит содержится в:
Harrison Healey
2016-06-01 16:05:36 -04:00
коммит произвёл Corey Hulen
родитель 3ce6dfc71e
Коммит 2ea54b9d1e
3 изменённых файлов: 20 добавлений и 7 удалений

Просмотреть файл

@@ -4,9 +4,13 @@
package model
import (
"regexp"
"strings"
)
var searchTermPuncStart = regexp.MustCompile(`^[^\pL\d\s#"]+`)
var searchTermPuncEnd = regexp.MustCompile(`[^\pL\d\s*"]+$`)
type SearchParams struct {
Terms string
IsHashtag bool
@@ -91,8 +95,8 @@ func parseSearchFlags(input []string) ([]string, [][2]string) {
if !isFlag {
// trim off surrounding punctuation (note that we leave trailing asterisks to allow wildcards)
word = puncStart.ReplaceAllString(word, "")
word = puncEndWildcard.ReplaceAllString(word, "")
word = searchTermPuncStart.ReplaceAllString(word, "")
word = searchTermPuncEnd.ReplaceAllString(word, "")
// and remove extra pound #s
word = hashtagStart.ReplaceAllString(word, "#")