fix: set gravatar size parameter is s

This commit is contained in:
LinkinStar 2022-10-28 11:01:42 +08:00
parent 97ab26663f
commit 5a16859e6b
2 changed files with 4 additions and 4 deletions

View File

@ -28,7 +28,7 @@ func Resize(originalAvatarURL string, sizePixel int) (resizedAvatarURL string) {
return originalAvatarURL
}
query := originalURL.Query()
query.Set("p", fmt.Sprintf("%d", sizePixel))
query.Set("s", fmt.Sprintf("%d", sizePixel))
originalURL.RawQuery = query.Encode()
return originalURL.String()
}

View File

@ -44,15 +44,15 @@ func TestResize(t *testing.T) {
originalAvatarURL: "https://www.gravatar.com/avatar/b2be4e4438f08a5e885be8de5f41fdd7",
sizePixel: 128,
},
wantResizedAvatarURL: "https://www.gravatar.com/avatar/b2be4e4438f08a5e885be8de5f41fdd7?p=128",
wantResizedAvatarURL: "https://www.gravatar.com/avatar/b2be4e4438f08a5e885be8de5f41fdd7?s=128",
},
{
name: "already resized url",
args: args{
originalAvatarURL: "https://www.gravatar.com/avatar/b2be4e4438f08a5e885be8de5f41fdd7?p=128",
originalAvatarURL: "https://www.gravatar.com/avatar/b2be4e4438f08a5e885be8de5f41fdd7?s=128",
sizePixel: 64,
},
wantResizedAvatarURL: "https://www.gravatar.com/avatar/b2be4e4438f08a5e885be8de5f41fdd7?p=64",
wantResizedAvatarURL: "https://www.gravatar.com/avatar/b2be4e4438f08a5e885be8de5f41fdd7?s=64",
},
{
name: "empty url",