UriQuery { public Optional<String> domain() { String host = host(); if (host == null) return Optional.empty(); Matcher matcher = DOMAIN_PATTERN.matcher(host); if (matcher.find()) { return Optional.of(matcher.group()); } return Optional.empty(); } private  UriQuery( String url ); String host(); Optional<String> domain(); static UriQuery uri( String value );  }
@Test public void testDomain() throws Exception { assertEquals("cnn.com", uri("http: assertEquals("cnn.com", uri("http: }