diff options
Diffstat (limited to 'model/utils.go')
-rw-r--r-- | model/utils.go | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/model/utils.go b/model/utils.go index 70b7e3bbd..695d4a0cb 100644 --- a/model/utils.go +++ b/model/utils.go @@ -71,16 +71,6 @@ func AppErrorFromJson(data io.Reader) *AppError { } } -func NewAppError(where string, message string, details string) *AppError { - ap := &AppError{} - ap.Message = message - ap.Where = where - ap.DetailedError = details - ap.StatusCode = 500 - ap.IsOAuth = false - return ap -} - func NewLocAppError(where string, id string, params map[string]interface{}, details string) *AppError { ap := &AppError{} ap.Id = id @@ -298,8 +288,9 @@ func Etag(parts ...interface{}) string { } var validHashtag = regexp.MustCompile(`^(#[A-Za-zäöüÄÖÜß]+[A-Za-z0-9äöüÄÖÜß_\-]*[A-Za-z0-9äöüÄÖÜß])$`) -var puncStart = regexp.MustCompile(`^[.,()&$!\?\[\]{}':;\\]+`) -var puncEnd = regexp.MustCompile(`[.,()&$#!\?\[\]{}';\\]+$`) +var puncStart = regexp.MustCompile(`^[.,()&$!\?\[\]{}':;\\<>\-+=%^*|]+`) +var hashtagStart = regexp.MustCompile(`^#{2,}`) +var puncEnd = regexp.MustCompile(`[.,()&$#!\?\[\]{}':;\\<>\-+=%^*|]+$`) func ParseHashtags(text string) (string, string) { words := strings.Fields(text) @@ -307,8 +298,13 @@ func ParseHashtags(text string) (string, string) { hashtagString := "" plainString := "" for _, word := range words { + // trim off surrounding punctuation word = puncStart.ReplaceAllString(word, "") word = puncEnd.ReplaceAllString(word, "") + + // and remove extra pound #s + word = hashtagStart.ReplaceAllString(word, "#") + if validHashtag.MatchString(word) { hashtagString += " " + word } else { |