split on first dot when using domain instead of black listed local part
This commit is contained in:
parent
bc3e5f1dd4
commit
97598c63dc
|
@ -39,24 +39,24 @@ 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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Jid parseOrFallbackToInvalid(String jid) {
|
public static Jid parseOrFallbackToInvalid(String jid) {
|
||||||
try {
|
try {
|
||||||
return Jid.of(jid);
|
return Jid.of(jid);
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
return InvalidJid.of(jid, true);
|
return InvalidJid.of(jid, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue