Skip to content

Commit c918521

Browse files
committed
use url.JoinPath instead of concatenation
Signed-off-by: Sean Banko <[email protected]>
1 parent 734ea73 commit c918521

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

Diff for: injectproxy/routes.go

+13-2
Original file line numberDiff line numberDiff line change
@@ -388,9 +388,20 @@ func NewRoutes(upstream *url.URL, label string, extractLabeler ExtractLabeler, o
388388
}
389389

390390
r.mux = mux
391+
392+
rulesPath, err := url.JoinPath(upstream.Path, "/api/v1/rules")
393+
if err != nil {
394+
return nil, err
395+
}
396+
397+
alertsPath, err := url.JoinPath(upstream.Path, "/api/v1/alerts")
398+
if err != nil {
399+
return nil, err
400+
}
401+
391402
r.modifiers = map[string]func(*http.Response) error{
392-
upstream.Path + "/api/v1/rules": modifyAPIResponse(r.filterRules),
393-
upstream.Path + "/api/v1/alerts": modifyAPIResponse(r.filterAlerts),
403+
rulesPath: modifyAPIResponse(r.filterRules),
404+
alertsPath: modifyAPIResponse(r.filterAlerts),
394405
}
395406
proxy.ModifyResponse = r.ModifyResponse
396407
proxy.ErrorHandler = r.errorHandler

0 commit comments

Comments
 (0)