private function isValidDomain($domain)
    {
        if (filter_var($domain, FILTER_VALIDATE_URL)) {
            return true;
        }

        $regex = '~^(https?:\/\/|(\*\.){1})?(\w.+)(\.)(?!\s)(?!\.\*)(\w{2,})$~i';
        return (bool) preg_match($regex, $domain);
    }