Skip to content

Commit

Permalink
prevent encoding empty topic segments (#90)
Browse files Browse the repository at this point in the history
* prevent encoding empty topic segments

* tidy
  • Loading branch information
paulwe authored Mar 15, 2024
1 parent 61ab094 commit ba2e5b9
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions pkg/info/channels.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,24 +115,18 @@ 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"...)
}
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...))
Expand Down

0 comments on commit ba2e5b9

Please sign in to comment.