From a2e2a93f6936d7718573703e0ee3acae56eb6e88 Mon Sep 17 00:00:00 2001 From: Kei Date: Thu, 12 Dec 2024 12:12:27 +0700 Subject: [PATCH] wip --- app/Helpers/Helper.php | 4 ++-- tests/Unit/Helpers/HelperTest.php | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/Helpers/Helper.php b/app/Helpers/Helper.php index 6fb69eff0..38802422b 100644 --- a/app/Helpers/Helper.php +++ b/app/Helpers/Helper.php @@ -60,8 +60,8 @@ public static function urlFormat( // Handle cases where host is too long or the limit is shorter than the host if ($hostLength >= $maxHostLength || $hostLength >= $adjustedLimit) { - $firstHalf = mb_substr($value, 0, intval($adjustedLimit * 0.7)); - $secondHalf = mb_substr($value, -intval($adjustedLimit * 0.3)); + $firstHalf = mb_substr($value, 0, intval($adjustedLimit * 0.8)); + $secondHalf = mb_substr($value, -intval($adjustedLimit * 0.2)); return $firstHalf . $trimMarker . $secondHalf; } diff --git a/tests/Unit/Helpers/HelperTest.php b/tests/Unit/Helpers/HelperTest.php index 9d325d0e0..93588b906 100644 --- a/tests/Unit/Helpers/HelperTest.php +++ b/tests/Unit/Helpers/HelperTest.php @@ -44,17 +44,17 @@ public function urlFormatWithTooLongHost(): void $url = 'http://theofficialabsolutelongestdomainnameregisteredontheworldwideweb.international/search?client=firefox-b-d&q=longets+domain'; $this->assertSame( - 'http://theofficialabsolutelongestdomainnameregisteredonthewo...refox-b-d&q=longets+domain', + 'http://theofficialabsolutelongestdomainnameregisteredontheworldwidewe...&q=longets+domain', Helper::urlFormat($url, limit: 90), ); $this->assertSame( - 'theofficialabsolutelongestdomainnameregisteredontheworld...fox-b-d&q=longets+domain', + 'theofficialabsolutelongestdomainnameregisteredontheworldwideweb....q=longets+domain', Helper::urlFormat($url, scheme: false, limit: 84), ); $this->assertSame( - 'https://hunterxhun...7_Hunter', + 'https://hunterxhunter...unter', Helper::urlFormat('https://hunterxhunter.fandom.com/wiki/Hunter_%C3%97_Hunter', limit: 30), ); }