"/user2/repo1/src/master": "/user2/repo1/src/branch/master",
"/user2/repo1/src/master/file.txt": "/user2/repo1/src/branch/master/file.txt",
"/user2/repo1/src/master/directory/file.txt": "/user2/repo1/src/branch/master/directory/file.txt",
+ "/user/avatar/Ghost/-1": "/img/avatar_default.png",
}
for link, redirectLink := range redirects {
req := NewRequest(t, "GET", link)
import (
"strconv"
+ "strings"
"code.gitea.io/gitea/models"
"code.gitea.io/gitea/modules/context"
log.Debug("Asked avatar for user %v and size %v", userName, size)
- user, err := models.GetUserByName(userName)
- if err != nil {
- if models.IsErrUserNotExist(err) {
- ctx.ServerError("Requested avatar for invalid user", err)
- } else {
- ctx.ServerError("Retrieving user by name", err)
+ var user *models.User
+ if strings.ToLower(userName) != "ghost" {
+ user, err = models.GetUserByName(userName)
+ if err != nil {
+ if models.IsErrUserNotExist(err) {
+ ctx.ServerError("Requested avatar for invalid user", err)
+ } else {
+ ctx.ServerError("Retrieving user by name", err)
+ }
+ return
}
- return
+ } else {
+ user = models.NewGhostUser()
}
ctx.Redirect(user.RealSizedAvatarLink(size))