Merge pull request #677 from mattermost/plt-50

PLT-50 Allowing channel names with underscores. Allow import of more slack channel names.
Этот коммит содержится в:
Joram Wilander
2015-09-14 14:32:15 -04:00
родитель 0d8e27ce94 7b3c2d6d85
Коммит 125b7dc71b
4 изменённых файлов: 21 добавлений и 6 удалений

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

@@ -158,7 +158,7 @@ func IsReservedTeamName(s string) bool {
func IsValidTeamName(s string) bool {
if !IsValidAlphaNum(s) {
if !IsValidAlphaNum(s, false) {
return false
}

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

@@ -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