URLUtils { public static String resolvePath(final String path) { if (StringUtils.isBlank(path)) { return path; } String resolvedPath = path.trim(); while (resolvedPath.contains(PathConstants.BACK_SLASH)) { resolvedPath = StringUtils.replace(resolvedPath, PathConstants.BACK_SLASH, PathConstants.SLASH); } while (resolvedPath.contains(PathConstants.DOUBLE_SLASH)) { resolvedPath = StringUtils.replace(resolvedPath, PathConstants.DOUBLE_SLASH, PathConstants.SLASH); } return resolvedPath; }  static String resolveRelativePath(URL archiveFileURL); static File resolveArchiveFile(URL archiveFileURL, String archiveFileExtensionName); @Nonnull static Map<String, List<String>> resolveParametersMap(String url); static String resolvePath(final String path); static String encode(String value, String encoding); static String encode(String value); static String decode(String value); static String decode(String value, String encoding); static boolean isDirectoryURL(URL url); static boolean isJarURL(URL url); static String buildURI(String... paths);  }
@Test public void testResolvePath() { String path = null; String expectedPath = null; String resolvedPath = null; resolvedPath = URLUtils.resolvePath(path); Assert.assertEquals(expectedPath, resolvedPath); path = ""; expectedPath = ""; resolvedPath = URLUtils.resolvePath(path); Assert.assertEquals(expectedPath, resolvedPath); path = "/abc/"; expectedPath = "/abc/"; resolvedPath = URLUtils.resolvePath(path); Assert.assertEquals(expectedPath, resolvedPath); path = " expectedPath = "/abc/"; resolvedPath = URLUtils.resolvePath(path); Assert.assertEquals(expectedPath, resolvedPath); path = " expectedPath = "/abc/"; resolvedPath = URLUtils.resolvePath(path); Assert.assertEquals(expectedPath, resolvedPath); }