mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
Trim trailing slashes to prevent OAuth2 URI mismatch errors (#4204)
Closes https://gitlab.com/gitlab-org/gitlab-mattermost/issues/84
This commit is contained in:
@@ -364,7 +364,7 @@ func (c *Context) SetTeamURLFromSession() {
|
||||
}
|
||||
|
||||
func (c *Context) SetSiteURL(url string) {
|
||||
c.siteURL = url
|
||||
c.siteURL = strings.TrimRight(url, "/")
|
||||
}
|
||||
|
||||
func (c *Context) GetTeamURLFromTeam(team *model.Team) string {
|
||||
|
||||
@@ -29,3 +29,24 @@ func TestCache(t *testing.T) {
|
||||
t.Fatal("should have one less")
|
||||
}
|
||||
}
|
||||
|
||||
func TestSiteURL(t *testing.T) {
|
||||
c := &Context{}
|
||||
|
||||
testCases := []struct {
|
||||
url string
|
||||
want string
|
||||
}{
|
||||
{"http://mattermost.com/", "http://mattermost.com"},
|
||||
{"http://mattermost.com", "http://mattermost.com"},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
c.SetSiteURL(tc.url)
|
||||
|
||||
if c.siteURL != tc.want {
|
||||
t.Fatalf("expected %s, got %s", tc.want, c.siteURL)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user