### Question:
URLDuplicatePathCanonicalizer { public String canonicalize(final String url) { if (url != null && url.contains("/../")) { StringBuffer result = new StringBuffer(); Matcher m = pattern.matcher(url); while (m.find()) { if (m.group(1).equals(m.group(2))) { m.appendReplacement(result, m.group(1)); } m.appendTail(result); } return result.toString(); } return url; }  String canonicalize(final String url);  }### Answer:
@Test public void testRemovesDuplicatePaths() throws Exception { String url = "http: String expected = "http: assertEquals(expected, c.canonicalize(url)); }
@Test public void testIgnoresRelativePaths() throws Exception { String url = "http: String expected = "http: assertEquals(expected, c.canonicalize(url)); }