Skip to content

Commit

Permalink
bugfix: club member image urls
Browse files Browse the repository at this point in the history
  • Loading branch information
irfan-dahir committed Oct 28, 2023
1 parent d5168f8 commit 126c631
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/Helper/Constants.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
class Constants
{
public const BASE_URL = 'https://myanimelist.net';
public const CDN_URL = 'https://cdn.myanimelist.net';

public const SEASONS = [
'Winter',
Expand Down
6 changes: 5 additions & 1 deletion src/Parser/Club/UserProfileParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,11 @@ public function getImage(): string
$this->crawler->filterXPath('//img[1]')->attr('data-src')
);

if (!preg_match("~^".Constants::BASE_URL."~", $imageUrl)) {
if (str_contains($imageUrl, Constants::CDN_URL)) {
return $imageUrl;
}

if (!str_contains($imageUrl, Constants::BASE_URL)) {
$imageUrl = Constants::BASE_URL.$imageUrl;
}

Expand Down

0 comments on commit 126c631

Please sign in to comment.