From 5e34e061d5326ccaaac83caee466a6f28e7e7d8f Mon Sep 17 00:00:00 2001 From: Jiajun Huang Date: Tue, 10 Dec 2019 15:59:11 +0800 Subject: [PATCH] use https for fetch gravatar by default (#20964) --- pkg/api/avatar/avatar.go | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/pkg/api/avatar/avatar.go b/pkg/api/avatar/avatar.go index ffbb51dd498..d2d33df144b 100644 --- a/pkg/api/avatar/avatar.go +++ b/pkg/api/avatar/avatar.go @@ -27,19 +27,9 @@ import ( gocache "github.com/patrickmn/go-cache" ) -var gravatarSource string - -func UpdateGravatarSource() { - srcCfg := "//secure.gravatar.com/avatar/" - - gravatarSource = srcCfg - if strings.HasPrefix(gravatarSource, "//") { - gravatarSource = "http:" + gravatarSource - } else if !strings.HasPrefix(gravatarSource, "http://") && - !strings.HasPrefix(gravatarSource, "https://") { - gravatarSource = "http://" + gravatarSource - } -} +const ( + gravatarSource = "https://secure.gravatar.com/avatar/" +) // Avatar represents the avatar object. type Avatar struct { @@ -126,8 +116,6 @@ func (this *CacheServer) Handler(ctx *macaron.Context) { } func NewCacheServer() *CacheServer { - UpdateGravatarSource() - return &CacheServer{ notFound: newNotFound(), cache: gocache.New(time.Hour, time.Hour*2),