summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--api/context.go2
-rw-r--r--api/context_test.go21
2 files changed, 22 insertions, 1 deletions
diff --git a/api/context.go b/api/context.go
index 81a2c021d..524ccf402 100644
--- a/api/context.go
+++ b/api/context.go
@@ -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 {
diff --git a/api/context_test.go b/api/context_test.go
index 88ba0f665..2227b7f65 100644
--- a/api/context_test.go
+++ b/api/context_test.go
@@ -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)
+ }
+ }
+
+}