Skip to content

Commit

Permalink
Merge pull request #94 from jamesgroat/ephemeral_topics
Browse files Browse the repository at this point in the history
make #ephemeral topic names valid to match nsq changes
  • Loading branch information
mreiferson committed Nov 20, 2014
2 parents 796ccde + 29ab697 commit faa636a
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,23 @@ const (
FrameTypeMessage int32 = 2
)

var validTopicNameRegex = regexp.MustCompile(`^[\.a-zA-Z0-9_-]+$`)
var validChannelNameRegex = regexp.MustCompile(`^[\.a-zA-Z0-9_-]+(#ephemeral)?$`)
var validTopicChannelNameRegex = regexp.MustCompile(`^[\.a-zA-Z0-9_-]+(#ephemeral)?$`)

// IsValidTopicName checks a topic name for correctness
func IsValidTopicName(name string) bool {
if len(name) > 64 || len(name) < 1 {
return false
}
return validTopicNameRegex.MatchString(name)
return isValidName(name)
}

// IsValidChannelName checks a channel name for correctness
func IsValidChannelName(name string) bool {
return isValidName(name)
}

func isValidName(name string) bool {
if len(name) > 64 || len(name) < 1 {
return false
}
return validChannelNameRegex.MatchString(name)
return validTopicChannelNameRegex.MatchString(name)
}

// ReadResponse is a client-side utility function to read from the supplied Reader
Expand Down

0 comments on commit faa636a

Please sign in to comment.