mirror of
https://github.com/hanzoai/psrpc.git
synced 2026-09-30 23:47:22 +00:00
prevent encoding empty topic segments (#90)
* prevent encoding empty topic segments * tidy
This commit is contained in:
+5
-11
@@ -115,9 +115,11 @@ func formatServerChannel(service string, topic []string, queue bool) string {
|
||||
defer scratch.Put(p)
|
||||
b := append(*p, "SRV."...)
|
||||
b = append(b, service...)
|
||||
if stringSliceLen(topic) > 0 {
|
||||
b = append(b, '.')
|
||||
b = appendChannelParts(b, '.', topic...)
|
||||
for _, t := range topic {
|
||||
if len(t) != 0 {
|
||||
b = append(b, '.')
|
||||
b = appendSanitizedChannelPart(b, t)
|
||||
}
|
||||
}
|
||||
if queue {
|
||||
b = append(b, ".Q"...)
|
||||
@@ -125,14 +127,6 @@ func formatServerChannel(service string, topic []string, queue bool) string {
|
||||
return string(b)
|
||||
}
|
||||
|
||||
func stringSliceLen(s []string) int {
|
||||
var n int
|
||||
for i := range s {
|
||||
n += len(s[i])
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func formatChannel(delim byte, parts ...any) string {
|
||||
buf := make([]byte, 0, 4*channelPartsLen(parts...)/3)
|
||||
return string(appendChannelParts(buf, delim, parts...))
|
||||
|
||||
Reference in New Issue
Block a user