1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2025-12-12 20:14:03 +00:00

Fix notADomain logic

This commit is contained in:
Samuel Štancl 2020-06-04 12:21:19 +02:00
parent 43d36205b8
commit 41127048f1

View file

@ -54,8 +54,11 @@ class InitializeTenancyBySubdomain extends InitializeTenancyByDomain
{ {
$parts = explode('.', $hostname); $parts = explode('.', $hostname);
$isLocalhost = count($parts) === 1;
$isIpAddress = count(array_filter($parts, 'is_numeric')) === count($parts);
// If we're on localhost or an IP address, then we're not visiting a subdomain. // If we're on localhost or an IP address, then we're not visiting a subdomain.
$notADomain = in_array(count($parts), [1, 4]); $notADomain = $isLocalhost || $isIpAddress;
$thirdPartyDomain = ! Str::endsWith($hostname, config('tenancy.central_domains')); $thirdPartyDomain = ! Str::endsWith($hostname, config('tenancy.central_domains'));
if ($notADomain || $thirdPartyDomain) { if ($notADomain || $thirdPartyDomain) {