fix(domains): allow adding domains without explicit ports (#11442)

This commit is contained in:
Andras Bacsai 2026-08-21 12:04:14 +02:00 committed by GitHub
parent 15072b9cf7
commit 83f1a2e503
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 7 additions and 2 deletions

View file

@ -4,11 +4,11 @@
class DomainUrlParts class DomainUrlParts
{ {
public static function compose(string $scheme, string $host, string $port = '', string $path = ''): string public static function compose(string $scheme, string $host, ?string $port = '', string $path = ''): string
{ {
$scheme = strtolower(trim($scheme)) === 'http' ? 'http' : 'https'; $scheme = strtolower(trim($scheme)) === 'http' ? 'http' : 'https';
$host = trim($host); $host = trim($host);
$port = trim($port); $port = trim((string) $port);
$path = trim($path); $path = trim($path);
if ($path !== '' && ! str_starts_with($path, '/') && ! str_starts_with($path, '?') && ! str_starts_with($path, '#')) { if ($path !== '' && ! str_starts_with($path, '/') && ! str_starts_with($path, '?') && ! str_starts_with($path, '#')) {

View file

@ -28,3 +28,8 @@
it('preserves an explicitly configured default port', function () { it('preserves an explicitly configured default port', function () {
expect(DomainUrlParts::split('https://app.example.com:443')['port'])->toBe('443'); expect(DomainUrlParts::split('https://app.example.com:443')['port'])->toBe('443');
}); });
it('composes a domain when Livewire hydrates an empty numeric port as null', function () {
expect(DomainUrlParts::compose('https', 'app.example.com', null))
->toBe('https://app.example.com');
});