Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
realodix committed Dec 12, 2024
1 parent 642e096 commit a2e2a93
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions app/Helpers/Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
6 changes: 3 additions & 3 deletions tests/Unit/Helpers/HelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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),
);
}
Expand Down

0 comments on commit a2e2a93

Please sign in to comment.