From 9c49ae16d3a0d64b6a002bde88de7d2574752724 Mon Sep 17 00:00:00 2001 From: claudemiro Date: Tue, 9 Aug 2016 23:54:06 -0300 Subject: [PATCH] Renamed regex to validate the channel name --- utils/utils.go | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/utils/utils.go b/utils/utils.go index 1f34630..97e3fdd 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -15,11 +15,7 @@ import ( "strings" ) -var validChannelName *regexp.Regexp - -func init() { - validChannelName = regexp.MustCompile("^[A-Za-z0-9_\\-=@,.;]+$") -} +var channelValidationRegex = regexp.MustCompile("^[A-Za-z0-9_\\-=@,.;]+$") // HashMAC Calculates the MAC signing with the given key and returns the hexadecimal encoded Result func HashMAC(message, key []byte) string { @@ -37,7 +33,7 @@ func GenerateSessionID() string { // IsChannelNameValid Verify if the channel name is valid 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