split on first dot when using domain instead of black listed local part

This commit is contained in:
Daniel Gultsch 2019-07-15 19:09:48 +02:00
parent bc3e5f1dd4
commit 97598c63dc

View file

@ -39,12 +39,12 @@ import rocks.xmpp.addr.Jid;
public class JidHelper { public class JidHelper {
private static List<String> LOCALPART_BLACKLIST = Arrays.asList("xmpp","jabber","me"); private static List<String> LOCAL_PART_BLACKLIST = Arrays.asList("xmpp", "jabber", "me");
public static String localPartOrFallback(Jid jid) { public static String localPartOrFallback(Jid jid) {
if (LOCALPART_BLACKLIST.contains(jid.getLocal().toLowerCase(Locale.ENGLISH))) { if (LOCAL_PART_BLACKLIST.contains(jid.getLocal().toLowerCase(Locale.ENGLISH))) {
final String domain = jid.getDomain(); final String domain = jid.getDomain();
final int index = domain.lastIndexOf('.'); final int index = domain.indexOf('.');
return index > 1 ? domain.substring(0, index) : domain; return index > 1 ? domain.substring(0, index) : domain;
} else { } else {
return jid.getLocal(); return jid.getLocal();