From 126c6316bb0ead5a73b3c8bc3961323a6c5602b7 Mon Sep 17 00:00:00 2001 From: Irfan Date: Sat, 28 Oct 2023 15:05:33 +0500 Subject: [PATCH] bugfix: club member image urls --- src/Helper/Constants.php | 1 + src/Parser/Club/UserProfileParser.php | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Helper/Constants.php b/src/Helper/Constants.php index 5be22ff9..158a81d9 100644 --- a/src/Helper/Constants.php +++ b/src/Helper/Constants.php @@ -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', diff --git a/src/Parser/Club/UserProfileParser.php b/src/Parser/Club/UserProfileParser.php index b862cf26..1dd34a8c 100644 --- a/src/Parser/Club/UserProfileParser.php +++ b/src/Parser/Club/UserProfileParser.php @@ -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; }