### Question:
UrlHelper { public static String getCanonicalUrl(String url) { if (url == null) { return ""; } try { URL urlObj = new URL(url); String protocol = urlObj.getProtocol(); String port = ""; if (urlObj.getPort() != -1 && urlObj.getPort() != urlObj.getDefaultPort()) { port = ":" + urlObj.getPort(); } String host = urlObj.getHost().toLowerCase(); String path = urlObj.getPath(); String[] query = null; if (urlObj.getQuery() != null) { query = urlObj.getQuery().split("&"); Arrays.sort(query); } String[] parts = path.split("/"); path = "/"; if (parts.length > 0) { for (int i = 0; i < parts.length; i++) { parts[i] = parts[i].trim(); if (parts[i].equals("..")) { parts[i] = ""; if (parts.length > 1 && i > 0) { parts[i - 1] = ""; } } } for (String part : parts) { if (part.length() > 0) { path += part + "/"; } } if (parts[parts.length - 1].contains(".")) { path = path.substring(0, path.length() - 1); } if (parts[parts.length - 1].contains("index") && query == null) { path = path.replaceAll("index\\..+$", ""); } } String queryPart = query != null ? "?" + StringUtils.join(query, "&") : ""; return protocol + ": } catch (MalformedURLException e) { LOGGER.trace("could not determine canonical url for {}", url); return ""; } } private  UrlHelper(); static String removeSessionId(String originalUrl); static void makeAbsoluteUrls(Document document); static String getBaseUrl(Document document); static String makeFullUrl(String pageUrl, String baseUrl, String linkUrl); static String makeFullUrl(String contextUrl, String linkUrl); static String getCleanUrl(String url); static String removeAnchors(String url); static String getDomain(String url, boolean includeProtocol, boolean includeSubdomain); static String getDomain(String url, boolean includeProtocol); static String getDomain(String url); static String getCanonicalUrl(String url); static String decodeParameter(String string); static String encodeParameter(String string); static List<String> extractUrls(String text); static boolean isLocalFile(URL url); static String createParameterString(List<Pair<String, String>> parameters); static List<Pair<String, String>> parseParams(String parameterString); static String parseBaseUrl(String url); static boolean isValidUrl(String url); static final Pattern URL_PATTERN; }### Answer:
@Test public void testGetCanonicalUrl() { assertEquals("http: UrlHelper.getCanonicalUrl("http: assertEquals( "http: UrlHelper .getCanonicalUrl("http: assertEquals("http: assertEquals( "http: UrlHelper .getCanonicalUrl("http: }