mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-05-22 01:34:18 +00:00
In many cases user avatar link should be an absolute URL with http host (#17420)
This commit is contained in:
parent
3676fafdac
commit
7c951fdd4a
3 changed files with 9 additions and 3 deletions
|
@ -9,6 +9,7 @@ import (
|
|||
"fmt"
|
||||
"image/png"
|
||||
"io"
|
||||
"strings"
|
||||
|
||||
"code.gitea.io/gitea/models/avatars"
|
||||
"code.gitea.io/gitea/models/db"
|
||||
|
@ -91,9 +92,13 @@ func (u *User) AvatarLinkWithSize(size int) string {
|
|||
return avatars.GenerateEmailAvatarFastLink(u.AvatarEmail, size)
|
||||
}
|
||||
|
||||
// AvatarLink returns a avatar link with default size
|
||||
// AvatarLink returns the full avatar link with http host
|
||||
func (u *User) AvatarLink() string {
|
||||
return u.AvatarLinkWithSize(0)
|
||||
link := u.AvatarLinkWithSize(0)
|
||||
if !strings.HasPrefix(link, "//") && !strings.Contains(link, "://") {
|
||||
return setting.AppURL + strings.TrimPrefix(link, setting.AppSubURL+"/")
|
||||
}
|
||||
return link
|
||||
}
|
||||
|
||||
// UploadAvatar saves custom avatar for user.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue