12345678910111213141516171819202122232425 |
- package protocol
- import (
- "regexp"
- )
- // var validTopicChannelNameRegex = regexp.MustCompile(`^[\.a-zA-Z0-9_-]+(#ephemeral)?$`)
- var validTopicChannelNameRegex = regexp.MustCompile("^[\u4e00-\u9fa5a-zA-Z0-9_-]+(#ephemeral)?$")
- // IsValidTopicName checks a topic name for correctness
- func IsValidTopicName(name string) bool {
- 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 validTopicChannelNameRegex.MatchString(name)
- }
|