new subsrcribe topic with wildcard *
This commit is contained in:
14
utils/utils.go
Normal file
14
utils/utils.go
Normal file
@@ -0,0 +1,14 @@
|
||||
package utils
|
||||
|
||||
import "strings"
|
||||
|
||||
func Matches(pattern, topic string) bool {
|
||||
if pattern == "*" {
|
||||
return true
|
||||
}
|
||||
if strings.HasSuffix(pattern, "/*") {
|
||||
prefix := strings.TrimSuffix(pattern, "/*")
|
||||
return strings.HasPrefix(topic, prefix+"/")
|
||||
}
|
||||
return pattern == topic
|
||||
}
|
Reference in New Issue
Block a user