Use unconditional strings.TrimSuffix
This commit is contained in:
parent
e82539b371
commit
04823e8da2
|
@ -291,10 +291,7 @@ func Setup(
|
||||||
return util.ErrorResponse(err)
|
return util.ErrorResponse(err)
|
||||||
}
|
}
|
||||||
// If there's a trailing slash, remove it
|
// If there's a trailing slash, remove it
|
||||||
eventType := vars["type"]
|
eventType := strings.TrimSuffix(vars["type"], "/")
|
||||||
if strings.HasSuffix(eventType, "/") {
|
|
||||||
eventType = eventType[:len(eventType)-1]
|
|
||||||
}
|
|
||||||
eventFormat := req.URL.Query().Get("format") == "event"
|
eventFormat := req.URL.Query().Get("format") == "event"
|
||||||
return OnIncomingStateTypeRequest(req.Context(), device, rsAPI, vars["roomID"], eventType, "", eventFormat)
|
return OnIncomingStateTypeRequest(req.Context(), device, rsAPI, vars["roomID"], eventType, "", eventFormat)
|
||||||
})).Methods(http.MethodGet, http.MethodOptions)
|
})).Methods(http.MethodGet, http.MethodOptions)
|
||||||
|
@ -315,11 +312,7 @@ func Setup(
|
||||||
return util.ErrorResponse(err)
|
return util.ErrorResponse(err)
|
||||||
}
|
}
|
||||||
emptyString := ""
|
emptyString := ""
|
||||||
eventType := vars["eventType"]
|
eventType := strings.TrimSuffix(vars["eventType"], "/")
|
||||||
// If there's a trailing slash, remove it
|
|
||||||
if strings.HasSuffix(eventType, "/") {
|
|
||||||
eventType = eventType[:len(eventType)-1]
|
|
||||||
}
|
|
||||||
return SendEvent(req, device, vars["roomID"], eventType, nil, &emptyString, cfg, rsAPI, nil)
|
return SendEvent(req, device, vars["roomID"], eventType, nil, &emptyString, cfg, rsAPI, nil)
|
||||||
}),
|
}),
|
||||||
).Methods(http.MethodPut, http.MethodOptions)
|
).Methods(http.MethodPut, http.MethodOptions)
|
||||||
|
|
Loading…
Reference in a new issue