diff --git a/library/Rules/Domain.php b/library/Rules/Domain.php index b6a365ca6..4290b496c 100644 --- a/library/Rules/Domain.php +++ b/library/Rules/Domain.php @@ -29,16 +29,12 @@ public function __construct($tldCheck = true) new Alnum('-'), new Not(new StartsWith('-')), new OneOf( - new Not( - new Contains('--') - ), - new AllOf( - new StartsWith('xn--'), - new Callback(function ($str) { - return substr_count($str, '--') == 1; - }) - ) - ) + new Not(new Contains('--')), + new Callback(function ($str) { + return substr_count($str, '--') == 1; + }) + ), + new Not(new EndsWith('-')) ); } diff --git a/tests/unit/Rules/DomainTest.php b/tests/unit/Rules/DomainTest.php index 1593e5da2..8324edf6f 100644 --- a/tests/unit/Rules/DomainTest.php +++ b/tests/unit/Rules/DomainTest.php @@ -67,6 +67,9 @@ public function providerForDomain() ['xn--bcher-kva.ch'], ['mail.xn--bcher-kva.ch'], ['example-hyphen.com'], + ['example--valid.com'], + ['std--a.com'], + ['r--w.com'], ]; } @@ -76,10 +79,10 @@ public function providerForNotDomain() [null], [''], ['2222222domain.local'], - ['example--invalid.com'], ['-example-invalid.com'], ['example.invalid.-com'], ['xn--bcher--kva.ch'], + ['example.invalid-.com'], ['1.2.3.256'], ['1.2.3.4'], ];