def is_valid_endpoint_url(endpoint_url):
 parts = urlsplit(endpoint_url)
 hostname = parts.hostname
 if (hostname is None):
  return False
 if (len(hostname) > 255):
  return False
 if (hostname[(-1)] == '.'):
  hostname = hostname[:(-1)]
 allowed = re.compile('^((?!-)[A-Z\\d-]{1,63}(?<!-)\\.)*((?!-)[A-Z\\d-]{1,63}(?<!-))$', re.IGNORECASE)
 return allowed.match(hostname)

def is_valid_endpoint_url ( endpoint_url ) : parts = urlsplit ( endpoint_url ) hostname = parts . hostname if ( hostname is None ) : return False if ( len ( hostname ) > 255 ) : return False if ( hostname [ ( - 1 ) ] == '.' ) : hostname = hostname [ : ( - 1 ) ] allowed = re . compile ( '^((?!-)[A-Z\\d-]{1,63}(?<!-)\\.)*((?!-)[A-Z\\d-]{1,63}(?<!-))$' , re . IGNORECASE ) return allowed . match ( hostname )
verify the endpoint_url is valid .