Skip to content

Commit

Permalink
Remove extension from URL to avoid to load the same image content
Browse files Browse the repository at this point in the history
  • Loading branch information
ottaviano committed Oct 6, 2019
1 parent 60cf5ea commit a7e914b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/Gravatar.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Gravatar extends Base
'wavatar',
];

private const URL = 'https://www.gravatar.com/avatar/%s.jpg?d=%s&size=%d';
private const URL = 'https://www.gravatar.com/avatar/%s?d=%s&size=%d';

public static function gravatarUrl(string $mode = null, string $email = null, int $size = 80): string
{
Expand Down
8 changes: 4 additions & 4 deletions tests/GravatarTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,25 @@ class GravatarTest extends TestCase
{
public function testDefaultUrlValues()
{
$this->assertRegExp('#^https://www\.gravatar\.com/avatar/\d+\.jpg\?d=retro&size=80#', Gravatar::gravatarUrl());
$this->assertRegExp('#^https://www\.gravatar\.com/avatar/\d+\?d=retro&size=80#', Gravatar::gravatarUrl());
}

public function testGravatarUrlAcceptsCustomMode()
{
$this->assertRegExp('#^https://www\.gravatar\.com/avatar/\d+\.jpg\?d=mp&size=80#', Gravatar::gravatarUrl('mp'));
$this->assertRegExp('#^https://www\.gravatar\.com/avatar/\d+\?d=mp&size=80#', Gravatar::gravatarUrl('mp'));
}

public function testGravatarUrlAcceptsCustomSize()
{
$this->assertRegExp('#^https://www\.gravatar\.com/avatar/\d+\.jpg\?d=retro&size=200#', Gravatar::gravatarUrl(null, null, 200));
$this->assertRegExp('#^https://www\.gravatar\.com/avatar/\d+\?d=retro&size=200#', Gravatar::gravatarUrl(null, null, 200));
}

public function testGravatarUrlAcceptsCustomEmail()
{
$email = '[email protected]';
$hash = md5(strtolower($email));

$this->assertRegExp("#^https://www\.gravatar\.com/avatar/${hash}\.jpg\?d=retro&size=80#", Gravatar::gravatarUrl(null, $email));
$this->assertRegExp("#^https://www\.gravatar\.com/avatar/${hash}\?d=retro&size=80#", Gravatar::gravatarUrl(null, $email));
}

public function testDownloadWithDefaults()
Expand Down

0 comments on commit a7e914b

Please sign in to comment.