From 97598c63dc979a5bf692562ef084a75132a94b7d Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Mon, 15 Jul 2019 19:09:48 +0200 Subject: [PATCH] split on first dot when using domain instead of black listed local part --- .../siacs/conversations/utils/JidHelper.java | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/utils/JidHelper.java b/src/main/java/eu/siacs/conversations/utils/JidHelper.java index 562e179ab..8a1510fd2 100644 --- a/src/main/java/eu/siacs/conversations/utils/JidHelper.java +++ b/src/main/java/eu/siacs/conversations/utils/JidHelper.java @@ -39,24 +39,24 @@ import rocks.xmpp.addr.Jid; public class JidHelper { - private static List LOCALPART_BLACKLIST = Arrays.asList("xmpp","jabber","me"); + private static List LOCAL_PART_BLACKLIST = Arrays.asList("xmpp", "jabber", "me"); - public static String localPartOrFallback(Jid jid) { - if (LOCALPART_BLACKLIST.contains(jid.getLocal().toLowerCase(Locale.ENGLISH))) { - final String domain = jid.getDomain(); - final int index = domain.lastIndexOf('.'); - return index > 1 ? domain.substring(0,index) : domain; - } else { - return jid.getLocal(); - } - } + public static String localPartOrFallback(Jid jid) { + if (LOCAL_PART_BLACKLIST.contains(jid.getLocal().toLowerCase(Locale.ENGLISH))) { + final String domain = jid.getDomain(); + final int index = domain.indexOf('.'); + return index > 1 ? domain.substring(0, index) : domain; + } else { + return jid.getLocal(); + } + } - public static Jid parseOrFallbackToInvalid(String jid) { - try { - return Jid.of(jid); - } catch (IllegalArgumentException e) { - return InvalidJid.of(jid, true); - } - } + public static Jid parseOrFallbackToInvalid(String jid) { + try { + return Jid.of(jid); + } catch (IllegalArgumentException e) { + return InvalidJid.of(jid, true); + } + } }