code: def _is_domain_match(domain: str, hostname: str) -> bool:
          
          if hostname == domain:
              return True
  
          if not hostname.endswith(domain):
              return False
  
          non_matching = hostname[:-len(domain)]
  
          if not non_matching.endswith("."):
              return False
  
          return not is_ip_address(hostname)
docs: Implements domain matching adhering to RFC 6265.