new subsrcribe topic with wildcard *

This commit is contained in:
Adrian Zuercher
2025-08-24 07:52:26 +02:00
parent fee2381a45
commit e99fd0710b
2 changed files with 22 additions and 3 deletions

14
utils/utils.go Normal file
View 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
}