@Test public void testGetBaseUrl() { assertEquals("Test remove /server", "http: Utils.getBaseUrl("http: assertEquals("Test remove /server/api/core/items", "https: Utils.getBaseUrl("https: assertEquals("Test remove trailing slash", "https: Utils.getBaseUrl("https: assertEquals("Test keep url", "https: Utils.getBaseUrl("https: assertEquals("Test keep url", "http: Utils.getBaseUrl("http: assertEquals("Test keep url", "http: Utils.getBaseUrl("http: assertNull("Test invalid URI returns null", Utils.getBaseUrl("&+,?/@=")); }
public static String getBaseUrl(String urlString) { try { URL url = new URL(urlString); String baseUrl = url.getProtocol() + ": if (url.getPort() != -1) { baseUrl += (":" + url.getPort()); } return baseUrl; } catch (MalformedURLException e) { return null; } }
Utils { public static String getBaseUrl(String urlString) { try { URL url = new URL(urlString); String baseUrl = url.getProtocol() + ": if (url.getPort() != -1) { baseUrl += (":" + url.getPort()); } return baseUrl; } catch (MalformedURLException e) { return null; } } }
Utils { public static String getBaseUrl(String urlString) { try { URL url = new URL(urlString); String baseUrl = url.getProtocol() + ": if (url.getPort() != -1) { baseUrl += (":" + url.getPort()); } return baseUrl; } catch (MalformedURLException e) { return null; } } private  Utils(); }
Utils { public static String getBaseUrl(String urlString) { try { URL url = new URL(urlString); String baseUrl = url.getProtocol() + ": if (url.getPort() != -1) { baseUrl += (":" + url.getPort()); } return baseUrl; } catch (MalformedURLException e) { return null; } } private  Utils(); static String getMD5(String data); static String getMD5(byte[] data); static byte[] getMD5Bytes(byte[] data); static String toHex(byte[] data); static String generateKey(); static String generateHexKey(); static synchronized byte[] generateBytesKey(); static void copy(final InputStream input, final OutputStream output); static void bufferedCopy(final InputStream source,
                                    final OutputStream destination); static String addEntities(String value); static long parseDuration(String duration); static synchronized Date parseISO8601Date(String s); static synchronized String formatISO8601Date(Date d); static java.util.Collection<E> emptyIfNull(java.util.Collection<E> collection); static String[] tokenize(String metadata); static String standardize(String schema, String element, String qualifier, String separator); static String getBaseUrl(String urlString); static String getHostName(String uriString); static String interpolateConfigsInString(String string); }
Utils { public static String getBaseUrl(String urlString) { try { URL url = new URL(urlString); String baseUrl = url.getProtocol() + ": if (url.getPort() != -1) { baseUrl += (":" + url.getPort()); } return baseUrl; } catch (MalformedURLException e) { return null; } } private  Utils(); static String getMD5(String data); static String getMD5(byte[] data); static byte[] getMD5Bytes(byte[] data); static String toHex(byte[] data); static String generateKey(); static String generateHexKey(); static synchronized byte[] generateBytesKey(); static void copy(final InputStream input, final OutputStream output); static void bufferedCopy(final InputStream source,
                                    final OutputStream destination); static String addEntities(String value); static long parseDuration(String duration); static synchronized Date parseISO8601Date(String s); static synchronized String formatISO8601Date(Date d); static java.util.Collection<E> emptyIfNull(java.util.Collection<E> collection); static String[] tokenize(String metadata); static String standardize(String schema, String element, String qualifier, String separator); static String getBaseUrl(String urlString); static String getHostName(String uriString); static String interpolateConfigsInString(String string);  }