From 0b6f85c20ed41a55f45af0f2bac25b997480ddbd Mon Sep 17 00:00:00 2001 From: Pawel Kosiec Date: Mon, 31 Jul 2023 15:21:50 +0200 Subject: [PATCH] Trim suffix for Mattermost URL --- pkg/bot/mattermost.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pkg/bot/mattermost.go b/pkg/bot/mattermost.go index f0086ad3f..5ee8ccd4f 100644 --- a/pkg/bot/mattermost.go +++ b/pkg/bot/mattermost.go @@ -77,9 +77,11 @@ func NewMattermost(ctx context.Context, log logrus.FieldLogger, commGroupName st return nil, err } - checkURL, err := url.Parse(cfg.URL) + mmURL := strings.TrimSuffix(cfg.URL, "/") + + checkURL, err := url.Parse(mmURL) if err != nil { - return nil, fmt.Errorf("while parsing Mattermost URL %q: %w", cfg.URL, err) + return nil, fmt.Errorf("while parsing Mattermost URL %q: %w", mmURL, err) } // Create WebSocketClient and handle messages @@ -88,7 +90,7 @@ func NewMattermost(ctx context.Context, log logrus.FieldLogger, commGroupName st webSocketURL = WebSocketSecureProtocol + checkURL.Host + checkURL.Path } - client := model.NewAPIv4Client(cfg.URL) + client := model.NewAPIv4Client(mmURL) client.SetOAuthToken(cfg.Token) botTeams, _, err := client.SearchTeams(ctx, &model.TeamSearch{ Term: cfg.Team,