Skip to content

Commit

Permalink
Trim suffix for Mattermost URL
Browse files Browse the repository at this point in the history
  • Loading branch information
pkosiec committed Jul 31, 2023
1 parent f1c8c2e commit 0b6f85c
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions pkg/bot/mattermost.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand Down

0 comments on commit 0b6f85c

Please sign in to comment.