From 04823e8da23973945f779f6b5d4a6b21ae4f9236 Mon Sep 17 00:00:00 2001 From: Till Faelligen Date: Tue, 10 Aug 2021 13:49:24 +0200 Subject: [PATCH] Use unconditional strings.TrimSuffix --- clientapi/routing/routing.go | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/clientapi/routing/routing.go b/clientapi/routing/routing.go index c6be8939d..d282306f2 100644 --- a/clientapi/routing/routing.go +++ b/clientapi/routing/routing.go @@ -291,10 +291,7 @@ func Setup( return util.ErrorResponse(err) } // If there's a trailing slash, remove it - eventType := vars["type"] - if strings.HasSuffix(eventType, "/") { - eventType = eventType[:len(eventType)-1] - } + eventType := strings.TrimSuffix(vars["type"], "/") eventFormat := req.URL.Query().Get("format") == "event" return OnIncomingStateTypeRequest(req.Context(), device, rsAPI, vars["roomID"], eventType, "", eventFormat) })).Methods(http.MethodGet, http.MethodOptions) @@ -315,11 +312,7 @@ func Setup( return util.ErrorResponse(err) } emptyString := "" - eventType := vars["eventType"] - // If there's a trailing slash, remove it - if strings.HasSuffix(eventType, "/") { - eventType = eventType[:len(eventType)-1] - } + eventType := strings.TrimSuffix(vars["eventType"], "/") return SendEvent(req, device, vars["roomID"], eventType, nil, &emptyString, cfg, rsAPI, nil) }), ).Methods(http.MethodPut, http.MethodOptions)