Fixed #1285 to support newer top level domain names (TLD) as well

Signed-off-by: Janos SUTO <sj@acts.hu>
This commit is contained in:
Janos SUTO
2023-03-18 16:32:14 +01:00
parent 81ffefbc65
commit 129f640421
3 changed files with 52 additions and 6 deletions

45
webui/tests/MiscTest.php Normal file
View File

@ -0,0 +1,45 @@
<?php
use PHPUnit\Framework\TestCase;
require_once dirname(dirname(__FILE__)) . '/config.php';
require_once dirname(dirname(__FILE__)) . '/system/model.php';
require_once dirname(dirname(__FILE__)) . '/system/loader.php';
require_once dirname(dirname(__FILE__)) . '/system/language.php';
require_once dirname(dirname(__FILE__)) . '/system/misc.php';
final class MiscTest extends TestCase
{
public function providerTestValiddomain() {
return [
['', 0],
['local', 1],
['@local', 1],
['aaa.fu', 1],
['@aaa.fu', 0],
['AAa.fu', 1],
['.aaa.fu', 0],
['-aaa.fu', 0],
['_aaa.fu', 0],
['2aaa.fu', 1],
['aaafu', 0],
['a.com.', 0],
['a.co.uk', 1],
['a.co.u2k', 1],
['a.com', 1],
['ccc.com', 1],
['aaa.bbb.ccc.com', 1],
['aaa.photography', 1],
];
}
/**
* @dataProvider providerTestValiddomain
*/
public function test_validdomain($data, $expected_result) {
$result = validdomain($data);
$this->assertEquals($result, $expected_result);
}
}