Skip to content

Commit

Permalink
Fixed extra . dot in urls without subdomain #115
Browse files Browse the repository at this point in the history
  • Loading branch information
givanz committed Apr 15, 2024
1 parent a7ed5bb commit 6f6a9fa
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions system/sites.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,13 +157,13 @@ public static function url($url, $host = null) {
&& ! is_numeric($host_matches['domain'] ?? null)) {
self :: $host_matches[$host] = $host_matches;

$has_subdomain = ! empty($host_matches['subdomain']) || ($matches['subdomain'] != '*');
$has_tld = ! empty($host_matches['tld']) || ($matches['tld'] != '*');
$subdomain = str_replace('*', $host_matches['subdomain'], $matches['subdomain']);
$domain = str_replace('*', $host_matches['domain'], $matches['domain']);
$tld = str_replace('*', $host_matches['tld'], $matches['tld']);

return $matches['prefix'] .
str_replace('*', $host_matches['subdomain'], $matches['subdomain']) . ($has_subdomain ? '.' : '') .
str_replace('*', $host_matches['domain'], $matches['domain']) . ($has_tld ? '.' : '') .
str_replace('*', $host_matches['tld'], $matches['tld']) .
$subdomain . ($subdomain ? '.' : '') .
$domain . ($tld ? '.' : '') . $tld .
($matches['path'] ?? '');
}

Expand Down

0 comments on commit 6f6a9fa

Please sign in to comment.