Renamed regex to validate the channel name

This commit is contained in:
claudemiro
2016-08-09 23:54:06 -03:00
parent 7a794c97d7
commit 9c49ae16d3
+2 -6
View File
@@ -15,11 +15,7 @@ import (
"strings" "strings"
) )
var validChannelName *regexp.Regexp var channelValidationRegex = regexp.MustCompile("^[A-Za-z0-9_\\-=@,.;]+$")
func init() {
validChannelName = regexp.MustCompile("^[A-Za-z0-9_\\-=@,.;]+$")
}
// HashMAC Calculates the MAC signing with the given key and returns the hexadecimal encoded Result // HashMAC Calculates the MAC signing with the given key and returns the hexadecimal encoded Result
func HashMAC(message, key []byte) string { func HashMAC(message, key []byte) string {
@@ -37,7 +33,7 @@ func GenerateSessionID() string {
// IsChannelNameValid Verify if the channel name is valid // IsChannelNameValid Verify if the channel name is valid
func IsChannelNameValid(channelName string) bool { func IsChannelNameValid(channelName string) bool {
return validChannelName.Match([]byte(channelName)) return channelValidationRegex.Match([]byte(channelName))
} }
// IsPrivateChannel Verify if the channel name represents a private channel // IsPrivateChannel Verify if the channel name represents a private channel