Skip to content

Commit

Permalink
s/getDomainFromUri/getHost/
Browse files Browse the repository at this point in the history
  • Loading branch information
maxme committed Dec 21, 2015
1 parent 0bca2ec commit 0851eb3
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@

public class UrlUtilsTest extends InstrumentationTestCase {
public void testGetDomainFromUrlWithEmptyStringDoesNotReturnNull() {
assertNotNull(UrlUtils.getDomainFromUrl(""));
assertNotNull(UrlUtils.getHost(""));
}

public void testGetDomainFromUrlWithNoHostDoesNotReturnNull() {
assertNotNull(UrlUtils.getDomainFromUrl("wordpress"));
assertNotNull(UrlUtils.getHost("wordpress"));
}

public void testGetDomainFromUrlWithHostReturnsHost() {
String url = "http://www.wordpress.com";
String host = UrlUtils.getDomainFromUrl(url);
String host = UrlUtils.getHost(url);

assertTrue(host.equals("www.wordpress.com"));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public static String getHomeURLOrHostNameFromAccountMap(Map<String, Object> acco
homeURL = StringUtils.removeTrailingSlash(homeURL);

if (homeURL.length() == 0) {
return StringUtils.getHost(MapUtils.getMapStr(account, "url"));
return UrlUtils.getHost(MapUtils.getMapStr(account, "url"));
}

return homeURL;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public static String blavatarFromUrl(final String url, int size) {
}
public static String blavatarFromUrl(final String url, int size, DefaultImage defaultImage) {
return "http://gravatar.com/blavatar/"
+ StringUtils.getMd5Hash(UrlUtils.getDomainFromUrl(url))
+ StringUtils.getMd5Hash(UrlUtils.getHost(url))
+ "?d=" + defaultImage.toString()
+ "&size=" + Integer.toString(size);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,16 @@ public static String urlDecode(final String text) {
}

/**
*
* @param urlString url to get domain from
* @return domain of uri if available. Empty string otherwise.
* @param urlString url to get host from
* @return host of uri if available. Empty string otherwise.
*/
public static String getDomainFromUrl(final String urlString) {
public static String getHost(final String urlString) {
if (urlString != null) {
Uri uri = Uri.parse(urlString);
if (uri.getHost() != null) {
return uri.getHost();
}
}

return "";
}

Expand Down

0 comments on commit 0851eb3

Please sign in to comment.