mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Small refactor for how HTTP_BASE is generated. Removing non-obvious regular expression. Fixes #1436
This commit is contained in:
parent
459e2ef1b0
commit
75483791f4
1 changed files with 10 additions and 6 deletions
|
@ -464,17 +464,21 @@ if (!function_exists('array_combine')) {
|
|||
break;
|
||||
case 'HTTP_BASE':
|
||||
$host = env('HTTP_HOST');
|
||||
$count = substr_count($host, '.');
|
||||
if ($count <= 1) {
|
||||
$parts = explode('.', $host);
|
||||
$count = count($parts);
|
||||
|
||||
if ($count === 1) {
|
||||
return '.' . $host;
|
||||
} elseif ($count === 2) {
|
||||
return '.' . $host;
|
||||
} elseif ($count === 3) {
|
||||
$gTLD = array('aero', 'asia', 'biz', 'cat', 'com', 'coop', 'edu', 'gov', 'info', 'int', 'jobs', 'mil', 'mobi', 'museum', 'name', 'net', 'org', 'pro', 'tel', 'travel', 'xxx');
|
||||
$domainName = explode('.', $host);
|
||||
if (in_array($domainName[1], $gTLD)) {
|
||||
$host = '.' . $host;
|
||||
if (in_array($parts[1], $gTLD)) {
|
||||
return '.' . $host;
|
||||
}
|
||||
}
|
||||
return preg_replace('/^([^.])*/i', null, $host);
|
||||
array_shift($parts);
|
||||
return '.' . implode('.', $parts);
|
||||
break;
|
||||
}
|
||||
return null;
|
||||
|
|
Loading…
Reference in a new issue