Add BootstrapTenantController and requests for tenant domain normalization; implement API route and tests

This commit is contained in:
2026-06-23 09:49:54 -03:00
parent 6d83d3dd7d
commit 3c6469617b
10 changed files with 399 additions and 34 deletions

View File

@@ -0,0 +1,36 @@
<?php
namespace App\Domains\Tenant\Support;
class TenantDomainNormalizer
{
public static function hasValue(mixed $domain): bool
{
return is_string($domain) && trim(urldecode($domain)) !== '';
}
public static function normalize(mixed $domain): ?string
{
if (! is_string($domain)) {
return null;
}
$decodedDomain = trim(urldecode($domain));
if ($decodedDomain === '') {
return null;
}
$candidate = str_contains($decodedDomain, '://')
? $decodedDomain
: "//{$decodedDomain}";
$host = parse_url($candidate, PHP_URL_HOST);
if (! is_string($host) || $host === '') {
return null;
}
return strtolower($host);
}
}