diff options
Diffstat (limited to '')
-rw-r--r-- | src/main/java/de/pixart/messenger/xmpp/InvalidJid.java | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/main/java/de/pixart/messenger/xmpp/InvalidJid.java b/src/main/java/de/pixart/messenger/xmpp/InvalidJid.java index fd4ca4b90..a22bd6cef 100644 --- a/src/main/java/de/pixart/messenger/xmpp/InvalidJid.java +++ b/src/main/java/de/pixart/messenger/xmpp/InvalidJid.java @@ -37,10 +37,20 @@ public class InvalidJid implements Jid { private final String value; - public InvalidJid(String jid) { + private InvalidJid(String jid) { this.value = jid; } + public static Jid of(String jid, boolean fallback) { + final int pos = jid.indexOf('/'); + if (fallback && pos >= 0 && jid.length() >= pos + 1) { + if (jid.substring(pos + 1).trim().isEmpty()) { + return Jid.ofEscaped(jid.substring(0, pos)); + } + } + return new InvalidJid(jid); + } + @Override @NonNull public String toString() { |