static boolean domainMatch(final String domain, final String host) {
        if (InetAddressUtils.isIPv4(host) || InetAddressUtils.isIPv6(host)) {
            return false;
        }
        final String normalizedDomain = domain.startsWith(".") ? domain.substring(1) : domain;
        if (host.endsWith(normalizedDomain)) {
            final int prefix = host.length() - normalizedDomain.length();
            // Either a full match or a prefix ending with a '.'
            if (prefix == 0) {
                return true;
            }
            return prefix > 1 && host.charAt(prefix - 1) == '.';
        }
        return false;
    }
Default instance of {@link BasicDomainHandler}.

@since 5.2
httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/BasicDomainHandler.java