1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-11-30 02:02:06 +01:00

Small fixes.

git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@2218 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
Matt Tucker 2004-01-28 21:30:13 +00:00 committed by mtucker
parent 37a3f14d3b
commit 37b56c9370

View file

@ -89,12 +89,12 @@ public class StringUtils {
} }
/** /**
* Returns the name portion of a XMPP address. For example, for the * Returns the server portion of a XMPP address. For example, for the
* address "matt@jivesoftware.com/Smack", "jivesoftware.com" would be returned. * address "matt@jivesoftware.com/Smack", "jivesoftware.com" would be returned.
* If no server is present in the address, the empty string will be returned. * If no server is present in the address, the empty string will be returned.
* *
* @param XMPPAddress the XMPP address. * @param XMPPAddress the XMPP address.
* @return the resource portion of the XMPP address. * @return the server portion of the XMPP address.
*/ */
public static String parseServer(String XMPPAddress) { public static String parseServer(String XMPPAddress) {
if (XMPPAddress == null) { if (XMPPAddress == null) {
@ -105,6 +105,9 @@ public class StringUtils {
if (atIndex + 1 > XMPPAddress.length()) { if (atIndex + 1 > XMPPAddress.length()) {
return ""; return "";
} }
if (atIndex < 0) {
atIndex = 0;
}
int slashIndex = XMPPAddress.indexOf("/"); int slashIndex = XMPPAddress.indexOf("/");
if (slashIndex > 0) { if (slashIndex > 0) {
return XMPPAddress.substring(atIndex + 1, slashIndex); return XMPPAddress.substring(atIndex + 1, slashIndex);
@ -115,7 +118,7 @@ public class StringUtils {
} }
/** /**
* Returns the name portion of a XMPP address. For example, for the * Returns the resource portion of a XMPP address. For example, for the
* address "matt@jivesoftware.com/Smack", "Smack" would be returned. If no * address "matt@jivesoftware.com/Smack", "Smack" would be returned. If no
* resource is present in the address, the empty string will be returned. * resource is present in the address, the empty string will be returned.
* *