@Test public void testDomainTrailingSlash() { HttpUrl url = HttpUrl.parse("http: HttpUrl actual = HttpUrls.host(url); HttpUrl expected = HttpUrl.parse("http: assertEquals(expected, actual); }
public static HttpUrl host(HttpUrl url) { List<String> pathSegments = url.pathSegments(); HttpUrl.Builder urlBuilder = url.newBuilder(); for (int i = pathSegments.size() - 1; i >= 0; i--) { urlBuilder.removePathSegment(i); } urlBuilder.query(null); return urlBuilder.build(); }
HttpUrls { public static HttpUrl host(HttpUrl url) { List<String> pathSegments = url.pathSegments(); HttpUrl.Builder urlBuilder = url.newBuilder(); for (int i = pathSegments.size() - 1; i >= 0; i--) { urlBuilder.removePathSegment(i); } urlBuilder.query(null); return urlBuilder.build(); } }
HttpUrls { public static HttpUrl host(HttpUrl url) { List<String> pathSegments = url.pathSegments(); HttpUrl.Builder urlBuilder = url.newBuilder(); for (int i = pathSegments.size() - 1; i >= 0; i--) { urlBuilder.removePathSegment(i); } urlBuilder.query(null); return urlBuilder.build(); }  }
HttpUrls { public static HttpUrl host(HttpUrl url) { List<String> pathSegments = url.pathSegments(); HttpUrl.Builder urlBuilder = url.newBuilder(); for (int i = pathSegments.size() - 1; i >= 0; i--) { urlBuilder.removePathSegment(i); } urlBuilder.query(null); return urlBuilder.build(); }  static HttpUrl host(HttpUrl url); }
HttpUrls { public static HttpUrl host(HttpUrl url) { List<String> pathSegments = url.pathSegments(); HttpUrl.Builder urlBuilder = url.newBuilder(); for (int i = pathSegments.size() - 1; i >= 0; i--) { urlBuilder.removePathSegment(i); } urlBuilder.query(null); return urlBuilder.build(); }  static HttpUrl host(HttpUrl url);  }