2 declare(strict_types = 1);
34 $jsCode[] =
'if (value === \'*\') {return value;}';
35 $jsCode[] =
'var parser = document.createElement(\'a\');';
36 $jsCode[] =
'parser.href = value.indexOf(\'://\') != -1 ? value : \'http://\' + value;';
37 $jsCode[] =
'return parser.host;';
38 return implode(
' ', $jsCode);
55 if (strpos($value,
'://') !==
false) {
65 if (strpos($value,
'/') !==
false) {
66 $checkValue = substr($value, 0, strpos($value,
'/'));
68 $validHostnameRegex =
'/^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])$/';
69 if (preg_match_all($validHostnameRegex, $checkValue, $matches, PREG_SET_ORDER) !==
false) {
70 if (!empty($matches)) {
76 $isIP = filter_var($value, FILTER_VALIDATE_IP) === $value;
90 $urlParts = parse_url($value);
91 if (!empty($urlParts[
'host'])) {
92 $value = $urlParts[
'host'];
96 $ipv6Pattern =
'/\[([a-zA-Z0-9:]*)\]/';
97 preg_match_all($ipv6Pattern, $urlParts[
'host'], $ipv6Matches, PREG_SET_ORDER);
98 if (!empty($ipv6Matches[0][1])) {
99 $value = $ipv6Matches[0][1];