summaryrefslogtreecommitdiffstats
path: root/model/utils.go
diff options
context:
space:
mode:
authorJoram Wilander <jwawilander@gmail.com>2015-09-14 14:32:15 -0400
committerJoram Wilander <jwawilander@gmail.com>2015-09-14 14:32:15 -0400
commit125b7dc71bb3ef00dc038632bf71737e5d25158b (patch)
treebea7dc36e248391ceba9323f07c9d516c7b5af1a /model/utils.go
parent0d8e27ce94c53b628109cc6ad11feeb2a1e4de88 (diff)
parent7b3c2d6d85ecee86fbc85b440e7028018b1090b1 (diff)
downloadchat-125b7dc71bb3ef00dc038632bf71737e5d25158b.tar.gz
chat-125b7dc71bb3ef00dc038632bf71737e5d25158b.tar.bz2
chat-125b7dc71bb3ef00dc038632bf71737e5d25158b.zip
Merge pull request #677 from mattermost/plt-50
PLT-50 Allowing channel names with underscores. Allow import of more slack channel names.
Diffstat (limited to 'model/utils.go')
-rw-r--r--model/utils.go12
1 files changed, 9 insertions, 3 deletions
diff --git a/model/utils.go b/model/utils.go
index 17d1c6317..d5122e805 100644
--- a/model/utils.go
+++ b/model/utils.go
@@ -202,7 +202,7 @@ func GetSubDomain(s string) (string, string) {
func IsValidChannelIdentifier(s string) bool {
- if !IsValidAlphaNum(s) {
+ if !IsValidAlphaNum(s, true) {
return false
}
@@ -213,10 +213,16 @@ func IsValidChannelIdentifier(s string) bool {
return true
}
+var validAlphaNumUnderscore = regexp.MustCompile(`^[a-z0-9]+([a-z\-\_0-9]+|(__)?)[a-z0-9]+$`)
var validAlphaNum = regexp.MustCompile(`^[a-z0-9]+([a-z\-0-9]+|(__)?)[a-z0-9]+$`)
-func IsValidAlphaNum(s string) bool {
- match := validAlphaNum.MatchString(s)
+func IsValidAlphaNum(s string, allowUnderscores bool) bool {
+ var match bool
+ if allowUnderscores {
+ match = validAlphaNumUnderscore.MatchString(s)
+ } else {
+ match = validAlphaNum.MatchString(s)
+ }
if !match {
return false