Fixing the url to gravatar to have hex encoding

This commit is contained in:
Joachim Hill-Grannec 2016-04-19 01:07:03 -04:00
parent 59edcd3389
commit 4f9f5673aa

View file

@ -3,17 +3,18 @@ package bitbucketserver
import ( import (
"net/http" "net/http"
"bytes" "bytes"
"log"
"io/ioutil" "io/ioutil"
"fmt" "fmt"
"strings" "strings"
"crypto/md5" "crypto/md5"
log "github.com/Sirupsen/logrus" log "github.com/Sirupsen/logrus"
"encoding/hex"
) )
func avatarLink(email string) (url string) { func avatarLink(email string) (url string) {
data := []byte(strings.ToLower(email)) hasher := md5.New()
emailHash := md5.Sum(data) hasher.Write([]byte(strings.ToLower(email)))
emailHash := fmt.Sprintf("%v", hex.EncodeToString(hasher.Sum(nil)))
avatarURL := fmt.Sprintf("http://www.gravatar.com/avatar/%s.jpg",emailHash) avatarURL := fmt.Sprintf("http://www.gravatar.com/avatar/%s.jpg",emailHash)
log.Info(avatarURL) log.Info(avatarURL)
return avatarURL return avatarURL