@Test public void testSplit1() { UrlSplitter.UrlParts parts = splitter.split("http: Assert.assertEquals("http: Assert.assertEquals("example.com", parts.getHost()); Assert.assertEquals(":8080", parts.getPort()); Assert.assertEquals("/path/here", parts.getPath()); Assert.assertEquals("?param=1", parts.getQuery()); }
public UrlParts split(String url) { Matcher matcher = URL_PATTERN.matcher(url.trim()); if (matcher.matches()) { UrlParts parts = new UrlParts(); parts.scheme = matcher.group(1); parts.host = matcher.group(2); parts.port = matcher.group(3); parts.path = matcher.group(4); parts.query = matcher.group(5); return parts; } return null; }
UrlSplitter { public UrlParts split(String url) { Matcher matcher = URL_PATTERN.matcher(url.trim()); if (matcher.matches()) { UrlParts parts = new UrlParts(); parts.scheme = matcher.group(1); parts.host = matcher.group(2); parts.port = matcher.group(3); parts.path = matcher.group(4); parts.query = matcher.group(5); return parts; } return null; } }
UrlSplitter { public UrlParts split(String url) { Matcher matcher = URL_PATTERN.matcher(url.trim()); if (matcher.matches()) { UrlParts parts = new UrlParts(); parts.scheme = matcher.group(1); parts.host = matcher.group(2); parts.port = matcher.group(3); parts.path = matcher.group(4); parts.query = matcher.group(5); return parts; } return null; }  }
UrlSplitter { public UrlParts split(String url) { Matcher matcher = URL_PATTERN.matcher(url.trim()); if (matcher.matches()) { UrlParts parts = new UrlParts(); parts.scheme = matcher.group(1); parts.host = matcher.group(2); parts.port = matcher.group(3); parts.path = matcher.group(4); parts.query = matcher.group(5); return parts; } return null; }  UrlParts split(String url); }
UrlSplitter { public UrlParts split(String url) { Matcher matcher = URL_PATTERN.matcher(url.trim()); if (matcher.matches()) { UrlParts parts = new UrlParts(); parts.scheme = matcher.group(1); parts.host = matcher.group(2); parts.port = matcher.group(3); parts.path = matcher.group(4); parts.query = matcher.group(5); return parts; } return null; }  UrlParts split(String url);  }