Refactoring

This commit is contained in:
M66B
2019-09-02 08:30:13 +02:00
parent 4d5794a51b
commit 03f97c7e3b
3 changed files with 17 additions and 9 deletions

View File

@@ -22,6 +22,7 @@ import java.net.UnknownHostException;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import javax.mail.Address;
import javax.mail.internet.InternetAddress;
@@ -316,4 +317,19 @@ public class ConnectionHelper {
return ok;
}
static boolean isSameDomain(String host1, String host2) {
String domain1 = getDomain(host1);
String domain2 = getDomain(host2);
return Objects.equals(domain1, domain2);
}
private static String getDomain(String host) {
if (host != null) {
String[] h = host.split("\\.");
if (h.length >= 2)
return h[h.length - 2] + "." + h[h.length - 1];
}
return host;
}
}