@Test public void setGetHostPortTest() { assertEquals("localhost", getHostPort("localhost")); assertEquals("localhost", getHostPort("https: assertEquals("localhost:123", getHostPort("https: assertEquals("[2001:0db8::765d]", getHostPort("[2001:0db8::765d]")); assertEquals("[2001:0db8::765d]:123", getHostPort("[2001:0db8::765d]:123")); assertEquals("[2001:0db8::765d]:123", getHostPort("https: }
public static String getHostPort(String addr) { if (addr == null) { return null; } int hostStart = getHostStart(addr); int portEnd = addr.indexOf('/', hostStart); if(portEnd < 0 && hostStart < 0) { return addr; } if(hostStart > 0) { if(portEnd < hostStart) { return addr.substring(hostStart); } return addr.substring(hostStart, portEnd); } return addr.substring(0, portEnd); }
AddressUtils { public static String getHostPort(String addr) { if (addr == null) { return null; } int hostStart = getHostStart(addr); int portEnd = addr.indexOf('/', hostStart); if(portEnd < 0 && hostStart < 0) { return addr; } if(hostStart > 0) { if(portEnd < hostStart) { return addr.substring(hostStart); } return addr.substring(hostStart, portEnd); } return addr.substring(0, portEnd); } }
AddressUtils { public static String getHostPort(String addr) { if (addr == null) { return null; } int hostStart = getHostStart(addr); int portEnd = addr.indexOf('/', hostStart); if(portEnd < 0 && hostStart < 0) { return addr; } if(hostStart > 0) { if(portEnd < hostStart) { return addr.substring(hostStart); } return addr.substring(hostStart, portEnd); } return addr.substring(0, portEnd); }  }
AddressUtils { public static String getHostPort(String addr) { if (addr == null) { return null; } int hostStart = getHostStart(addr); int portEnd = addr.indexOf('/', hostStart); if(portEnd < 0 && hostStart < 0) { return addr; } if(hostStart > 0) { if(portEnd < hostStart) { return addr.substring(hostStart); } return addr.substring(hostStart, portEnd); } return addr.substring(0, portEnd); }  static int getPort(String addr); static boolean hasPort(String addr); static String setPort(String address, int port); static boolean isIpv6(String url); static String getHostPort(String addr); static boolean isHttps(String url); static String getHost(String addr); static String setHost(String addr, String host); static boolean isLocal(String host); }
AddressUtils { public static String getHostPort(String addr) { if (addr == null) { return null; } int hostStart = getHostStart(addr); int portEnd = addr.indexOf('/', hostStart); if(portEnd < 0 && hostStart < 0) { return addr; } if(hostStart > 0) { if(portEnd < hostStart) { return addr.substring(hostStart); } return addr.substring(hostStart, portEnd); } return addr.substring(0, portEnd); }  static int getPort(String addr); static boolean hasPort(String addr); static String setPort(String address, int port); static boolean isIpv6(String url); static String getHostPort(String addr); static boolean isHttps(String url); static String getHost(String addr); static String setHost(String addr, String host); static boolean isLocal(String host);  }