Classes/Evaluation/SourceHost.php
public function evaluateFieldValue(string $value): string
    {
        // 1) Special case: * means any domain
        if ($value === '*') {
            return $value;
        }

        // 2) Check if value contains a protocol like http:// https:// etc...
        if (strpos($value, '://') !== false) {
            $tmp = $this->parseUrl($value);
            if (!empty($tmp)) {
                return $tmp;
            }
        }

        // 3) Check domain name
        // remove anything after the first "/"
        $checkValue = $value;
        if (strpos($value, '/') !== false) {
            $checkValue = substr($value, 0, strpos($value, '/'));
        }
        $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])$/';
        if (preg_match_all($validHostnameRegex, $checkValue, $matches, PREG_SET_ORDER) !== false) {
            if (!empty($matches)) {
                return $checkValue;
            }
        }

        // 4) IPv4 or IPv6
        $isIP = filter_var($value, FILTER_VALIDATE_IP) === $value;
        if ($isIP) {
            return $value;
        }

        return '';
    }
public function evaluateFieldValue(string $value): string
    {
        // 1) Special case: * means any domain
        if ($value === '*') {
            return $value;
        }

        // 2) Check if value contains a protocol like http:// https:// etc...
        if (strpos($value, '://') !== false) {
            $tmp = $this->parseUrl($value);
            if (!empty($tmp)) {
                return $tmp;
            }
        }

        // 3) Check domain name
        // remove anything after the first "/"
        $checkValue = $value;
        if (strpos($value, '/') !== false) {
            $checkValue = substr($value, 0, strpos($value, '/'));
        }
        $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])$/';
        if (preg_match_all($validHostnameRegex, $checkValue, $matches, PREG_SET_ORDER) !== false) {
            if (!empty($matches)) {
                return $checkValue;
            }
        }

        // 4) IPv4 or IPv6
        $isIP = filter_var($value, FILTER_VALIDATE_IP) === $value;
        if ($isIP) {
            return $value;
        }

        return '';
    }
public function evaluateFieldValue ( string $ value ) : string { // 1) Special case: * means any domain if ( $ value === '*' ) { return $ value ; } // 2) Check if value contains a protocol like http:// https:// etc... if ( strpos ( $ value , '://' ) !== false ) { $ tmp = $ this -> parseUrl ( $ value ) ; if ( ! empty ( $ tmp ) ) { return $ tmp ; } } // 3) Check domain name // remove anything after the first "/" $ checkValue = $ value ; if ( strpos ( $ value , '/' ) !== false ) { $ checkValue = substr ( $ value , 0 , strpos ( $ value , '/' ) ) ; } $ 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])$/' ; if ( preg_match_all ( $ validHostnameRegex , $ checkValue , $ matches , PREG_SET_ORDER ) !== false ) { if ( ! empty ( $ matches ) ) { return $ checkValue ; } } // 4) IPv4 or IPv6 $ isIP = filter_var ( $ value , FILTER_VALIDATE_IP ) === $ value ; if ( $ isIP ) { return $ value ; } return '' ; }
Server-side removing of protocol on save

@param string $value The field value to be evaluated
@return string Evaluated field value
Server - side removing of protocol on save