PathUtils { public static String normalizePath(String path) { Objects.requireNonNull(path, "path must not be null"); return path.isEmpty() || path.equals("/*") ? "" : ensureNotEndingSlash(ensureStartingSlash(path)); }  static String noStartingSlash(String path); static boolean hasStartingSlash(String path); static String noPrefix(String path, String prefix); static String ensureStartingSlash(String path); static String ensureEndingSlash(String path); static String ensureNotEndingSlash(String path); static String normalizePath(String path);  }
@Test public void normalizePath() { assertThat(PathUtils.normalizePath(""), is("")); assertThat(PathUtils.normalizePath("/*"), is("")); assertThat(PathUtils.ensureStartingSlash("/"), is("/")); assertThat(PathUtils.normalizePath("/foo/bar/"), is("/foo/bar")); assertThat(PathUtils.normalizePath("foo/bar"), is("/foo/bar")); }