@Test public void testSimplifyUrl() { String url = "http: System.out.println(UrlUtil.simplifyUrl(url)); }
public static String simplifyUrl(String url) { int index = url.indexOf(": if (index != -1) { String urlHead = url.substring(0, index + 2); String urlTail = url.substring(index + 2).replaceAll("/+", "/"); String finalUrl = new StringBuilder().append(urlHead).append(urlTail).toString(); return finalUrl; } else { return url.replaceAll("/+", "/"); } }
UrlUtil { public static String simplifyUrl(String url) { int index = url.indexOf(": if (index != -1) { String urlHead = url.substring(0, index + 2); String urlTail = url.substring(index + 2).replaceAll("/+", "/"); String finalUrl = new StringBuilder().append(urlHead).append(urlTail).toString(); return finalUrl; } else { return url.replaceAll("/+", "/"); } } }
UrlUtil { public static String simplifyUrl(String url) { int index = url.indexOf(": if (index != -1) { String urlHead = url.substring(0, index + 2); String urlTail = url.substring(index + 2).replaceAll("/+", "/"); String finalUrl = new StringBuilder().append(urlHead).append(urlTail).toString(); return finalUrl; } else { return url.replaceAll("/+", "/"); } }  }
UrlUtil { public static String simplifyUrl(String url) { int index = url.indexOf(": if (index != -1) { String urlHead = url.substring(0, index + 2); String urlTail = url.substring(index + 2).replaceAll("/+", "/"); String finalUrl = new StringBuilder().append(urlHead).append(urlTail).toString(); return finalUrl; } else { return url.replaceAll("/+", "/"); } }  static String urlJoin(String url, Map<String, String> params); static String simplifyUrl(String url); }
UrlUtil { public static String simplifyUrl(String url) { int index = url.indexOf(": if (index != -1) { String urlHead = url.substring(0, index + 2); String urlTail = url.substring(index + 2).replaceAll("/+", "/"); String finalUrl = new StringBuilder().append(urlHead).append(urlTail).toString(); return finalUrl; } else { return url.replaceAll("/+", "/"); } }  static String urlJoin(String url, Map<String, String> params); static String simplifyUrl(String url);  }