### Question:
UrlUtils { public static String canonicalizeUrl(String url, String refer) { URL base; try { try { base = new URL(refer); } catch (MalformedURLException e) { URL abs = new URL(refer); return abs.toExternalForm(); } if (url.startsWith("?")) url = base.getPath() + url; URL abs = new URL(base, url); return abs.toExternalForm(); } catch (MalformedURLException e) { return ""; } }  static String canonicalizeUrl(String url, String refer); static String encodeIllegalCharacterInUrl(String url); static String fixIllegalCharacterInUrl(String url); static String getHost(String url); static String removeProtocol(String url); static String getDomain(String url); static String removePort(String domain); static String getPath(String url); static List<Request> convertToRequests(Collection<String> urls); static List<String> convertToUrls(Collection<Request> requests); static String getCharset(String contentType);  }### Answer:
@Test public void test_relative_url() throws Exception { String url = "http: String absUrl = UrlUtils.canonicalizeUrl("123", url); Assert.assertEquals(absUrl, "http: absUrl = UrlUtils.canonicalizeUrl("../123", url); Assert.assertEquals(absUrl, "http: url = "http: absUrl = UrlUtils.canonicalizeUrl("../../123", url); Assert.assertEquals(absUrl, "http: }