Strings { public static String getDomain(String url) { String result = url; if (!isNullOrEmpty(url)) { int index = url.indexOf(SCHEME_HOST_SEPARATOR); if (index != INDEX_NOT_FOUND) { int slash = url.substring(index + SCHEME_HOST_SEPARATOR.length()).indexOf('/'); if (slash != INDEX_NOT_FOUND) { result = url.substring(0, index + slash + SCHEME_HOST_SEPARATOR.length()); } int questionMark = url.substring(index + SCHEME_HOST_SEPARATOR.length()).indexOf('?'); if (questionMark != INDEX_NOT_FOUND) { result = url.substring(0, index + questionMark + SCHEME_HOST_SEPARATOR.length()); } } } return result; } private  Strings(); static String abbreviate(String str, int offset, int maxWidth); static String abbreviateMiddle(String string, int maxLength); static String abbreviateFqClassName(String fqcn); static String capitalize(String str); static String substringAfterLast(String str, String separator); static String strip(String str, String stripChars); static String stripStart(String str, String stripChars); static String stripEnd(String str, String stripChars); static String getParent(String path); static String getDomain(String url); static String sanitize(String str);  }
@Test public void getDomain() throws Exception { assertNull(Strings.getDomain(null)); assertEquals("", Strings.getDomain("")); assertEquals("a", Strings.getDomain("a")); assertEquals("http: assertEquals("http: assertEquals("http: assertEquals("http: assertEquals("http: }