Allow slashes for MQTT topic, fixes #410

This commit is contained in:
tidwall 2019-02-12 06:58:43 -07:00
parent 30f903bd51
commit 99508c9af7
1 changed files with 8 additions and 3 deletions

View File

@ -404,10 +404,15 @@ func parseEndpoint(s string) (Endpoint, error) {
// Parsing MQTT queue name
if len(sp) > 1 {
var err error
endpoint.MQTT.QueueName, err = url.QueryUnescape(sp[1])
if err != nil {
return endpoint, errors.New("invalid MQTT topic name")
var parts []string
for _, part := range sp[1:] {
part, err = url.QueryUnescape(part)
if err != nil {
return endpoint, errors.New("invalid MQTT topic name")
}
parts = append(parts, part)
}
endpoint.MQTT.QueueName = strings.Join(parts, "/")
}
// Parsing additional params