@Test public void testGetHostName() { assertEquals("Test remove HTTP", "dspace.org", Utils.getHostName("http: assertEquals("Test remove HTTPS", "dspace.org", Utils.getHostName("https: assertEquals("Test remove trailing slash", "dspace.org", Utils.getHostName("https: assertEquals("Test remove www.", "dspace.org", Utils.getHostName("https: assertEquals("Test keep other prefixes", "demo.dspace.org", Utils.getHostName("https: assertNull("Test invalid URI returns null", Utils.getHostName("&+,?/@=")); }
public static String getHostName(String uriString) { try { URI uri = new URI(uriString); String hostname = uri.getHost(); if (hostname != null) { return hostname.startsWith("www.") ? hostname.substring(4) : hostname; } return hostname; } catch (URISyntaxException e) { return null; } }
Utils { public static String getHostName(String uriString) { try { URI uri = new URI(uriString); String hostname = uri.getHost(); if (hostname != null) { return hostname.startsWith("www.") ? hostname.substring(4) : hostname; } return hostname; } catch (URISyntaxException e) { return null; } } }
Utils { public static String getHostName(String uriString) { try { URI uri = new URI(uriString); String hostname = uri.getHost(); if (hostname != null) { return hostname.startsWith("www.") ? hostname.substring(4) : hostname; } return hostname; } catch (URISyntaxException e) { return null; } } private  Utils(); }
Utils { public static String getHostName(String uriString) { try { URI uri = new URI(uriString); String hostname = uri.getHost(); if (hostname != null) { return hostname.startsWith("www.") ? hostname.substring(4) : hostname; } return hostname; } catch (URISyntaxException 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 getHostName(String uriString) { try { URI uri = new URI(uriString); String hostname = uri.getHost(); if (hostname != null) { return hostname.startsWith("www.") ? hostname.substring(4) : hostname; } return hostname; } catch (URISyntaxException 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);  }