mirror of
https://github.com/archtechx/tenancy.git
synced 2026-05-06 18:04:03 +00:00
Make central domain order not matter in isSubdomain()
This commit is contained in:
parent
3976880dcb
commit
f4ee0a7943
2 changed files with 8 additions and 7 deletions
|
|
@ -61,11 +61,11 @@ class DomainTenantResolver extends Contracts\CachedTenantResolver
|
||||||
{
|
{
|
||||||
$centralDomains = Arr::wrap(config('tenancy.identification.central_domains'));
|
$centralDomains = Arr::wrap(config('tenancy.identification.central_domains'));
|
||||||
|
|
||||||
foreach ($centralDomains as $centralDomain) {
|
if (in_array($domain, $centralDomains, true)) {
|
||||||
if ($domain === $centralDomain) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach ($centralDomains as $centralDomain) {
|
||||||
if (Str::endsWith($domain, '.' . $centralDomain)) {
|
if (Str::endsWith($domain, '.' . $centralDomain)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -110,10 +110,11 @@ test('we cant use a subdomain that doesnt belong to our central domains', functi
|
||||||
});
|
});
|
||||||
|
|
||||||
test('domain resolver correctly determines if string is a subdomain', function() {
|
test('domain resolver correctly determines if string is a subdomain', function() {
|
||||||
config(['tenancy.identification.central_domains' => ['app.test']]);
|
config(['tenancy.identification.central_domains' => ['site.com', 'blog.site.com']]);
|
||||||
|
|
||||||
expect(DomainTenantResolver::isSubdomain('foo.app.test'))->toBeTrue();
|
expect(DomainTenantResolver::isSubdomain('blog.site.com'))->toBeFalse();
|
||||||
expect(DomainTenantResolver::isSubdomain('fooapp.test'))->toBeFalse();
|
expect(DomainTenantResolver::isSubdomain('tenant.site.com'))->toBeTrue();
|
||||||
|
expect(DomainTenantResolver::isSubdomain('tenantsite.com'))->toBeFalse();
|
||||||
});
|
});
|
||||||
|
|
||||||
class SubdomainTenant extends Models\Tenant
|
class SubdomainTenant extends Models\Tenant
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue