Python

Check hostname requires server hostname - SOLVED

Check hostname requires server hostname - SOLVED, someone asked me to explain?
I got the following error in python project "check hostname requires server hostname" 
CODE:
    parsed_url = urlparse(domain)
    domain = parsed_url.netloc
    
    context = ssl.create_default_context()
    conn = context.wrap_socket(socket.socket(socket.AF_INET), server_hostname=domain)


    conn.connect((domain, 443))
To avoid this error, you can normalize the input to extract the correct domain name.
UPDATED CODE:
    parsed_url = urlparse(domain if domain.startswith(('http://','https://')) else 'http://'+ domain)
domain = parsed_url.netloc context = ssl.create_default_context() conn = context.wrap_socket(socket.socket(socket.AF_INET), server_hostname=domain) conn.connect((domain, 443))

Post your comments / questions