UrlUtils { public static String format(String url) { int index = url.indexOf(": if (index == -1) { return url.replaceAll("/+", "/"); } String prefix = url.substring(0, index + 3); String following = url.substring(index + 3); return prefix + following.replaceAll("/+", "/"); }  static String format(String url);  }
@Test public void testFormat(){ Assert.assertEquals("http: Assert.assertEquals("localhost/a/b/c", UrlUtils.format("localhost/a/b/c")); Assert.assertEquals("http: Assert.assertEquals("localhost/a/b/c", UrlUtils.format("localhost }