Allow size parameter to be omitted (#468)
This commit is contained in:
parent
48eecda67e
commit
d554270136
1 changed files with 8 additions and 3 deletions
5
user.go
5
user.go
|
@ -30,6 +30,8 @@ func (u *User) Mention() string {
|
||||||
|
|
||||||
// AvatarURL returns a URL to the user's avatar.
|
// AvatarURL returns a URL to the user's avatar.
|
||||||
// size: The size of the user's avatar as a power of two
|
// size: The size of the user's avatar as a power of two
|
||||||
|
// if size is an empty string, no size parameter will
|
||||||
|
// be added to the URL.
|
||||||
func (u *User) AvatarURL(size string) string {
|
func (u *User) AvatarURL(size string) string {
|
||||||
var URL string
|
var URL string
|
||||||
if strings.HasPrefix(u.Avatar, "a_") {
|
if strings.HasPrefix(u.Avatar, "a_") {
|
||||||
|
@ -38,5 +40,8 @@ func (u *User) AvatarURL(size string) string {
|
||||||
URL = EndpointUserAvatar(u.ID, u.Avatar)
|
URL = EndpointUserAvatar(u.ID, u.Avatar)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if size != "" {
|
||||||
return URL + "?size=" + size
|
return URL + "?size=" + size
|
||||||
|
}
|
||||||
|
return URL
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue