summaryrefslogtreecommitdiffstats
path: root/model
diff options
context:
space:
mode:
Diffstat (limited to 'model')
-rw-r--r--model/utils.go6
-rw-r--r--model/utils_test.go24
2 files changed, 27 insertions, 3 deletions
diff --git a/model/utils.go b/model/utils.go
index 5596b06ff..617c95efd 100644
--- a/model/utils.go
+++ b/model/utils.go
@@ -273,9 +273,9 @@ func Etag(parts ...interface{}) string {
return etag
}
-var validHashtag = regexp.MustCompile(`^(#[A-Za-z]+[A-Za-z0-9_\-]*[A-Za-z0-9])$`)
-var puncStart = regexp.MustCompile(`^[.,()&$!\[\]{}':;\\]+`)
-var puncEnd = regexp.MustCompile(`[.,()&$#!\[\]{}';\\]+$`)
+var validHashtag = regexp.MustCompile(`^(#[A-Za-zäöüÄÖÜß]+[A-Za-z0-9äöüÄÖÜß_\-]*[A-Za-z0-9äöüÄÖÜß])$`)
+var puncStart = regexp.MustCompile(`^[.,()&$!\?\[\]{}':;\\]+`)
+var puncEnd = regexp.MustCompile(`[.,()&$#!\?\[\]{}';\\]+$`)
func ParseHashtags(text string) (string, string) {
words := strings.Fields(text)
diff --git a/model/utils_test.go b/model/utils_test.go
index 1f1e5f023..512a026e4 100644
--- a/model/utils_test.go
+++ b/model/utils_test.go
@@ -81,3 +81,27 @@ func TestEtag(t *testing.T) {
t.Fatal()
}
}
+
+var hashtags map[string]string = map[string]string{
+ "#test": "#test",
+ "test": "",
+ "#test123": "#test123",
+ "#123test123": "",
+ "#test-test": "#test-test",
+ "#test?": "#test",
+ "hi #there": "#there",
+ "#bug #idea": "#bug #idea",
+ "#bug or #gif!": "#bug #gif",
+ "#hüllo": "#hüllo",
+ "#?test": "",
+ "#-test": "",
+ "#yo_yo": "#yo_yo",
+}
+
+func TestParseHashtags(t *testing.T) {
+ for input, output := range hashtags {
+ if o, _ := ParseHashtags(input); o != output {
+ t.Fatal("expected=" + output + " actual=" + o)
+ }
+ }
+}