public static String extractHost(URI uri) { // Extract the host part from the URI. String host = uri.getHost(); if (host != null) { return host; } // According to Issue#74, URI.getHost() method returns null in // the following environment when the host part of the URI is // a host name. // // - Samsung Galaxy S3 + Android API 18 // - Samsung Galaxy S4 + Android API 21 // // The following is a workaround for the issue. // Extract the host part from the authority part of the URI. host = extractHostFromAuthorityPart(uri.getRawAuthority()); if (host != null) { return host; } // Extract the host part from the entire URI. return extractHostFromEntireUri(uri.toString()); }
public static String extractHost(URI uri) { // Extract the host part from the URI. String host = uri.getHost(); if (host != null) { return host; } // According to Issue#74, URI.getHost() method returns null in // the following environment when the host part of the URI is // a host name. // // - Samsung Galaxy S3 + Android API 18 // - Samsung Galaxy S4 + Android API 21 // // The following is a workaround for the issue. // Extract the host part from the authority part of the URI. host = extractHostFromAuthorityPart(uri.getRawAuthority()); if (host != null) { return host; } // Extract the host part from the entire URI. return extractHostFromEntireUri(uri.toString()); }