Merge branch 'feat/gravatar' into 'main'

fix: set gravatar size parameter is s

See merge request opensource/answer!119
This commit is contained in:
linkinstar 2022-10-28 03:10:20 +00:00
commit 09f1e8dde7
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",