PathPrefixUtil { public static String sanitize(String prefix) { if (prefix == null) { return ""; } if (prefix.isEmpty()) { return prefix; } prefix = prefix.trim(); if (!prefix.startsWith("/")) { prefix = "/" + prefix; } if (prefix.endsWith("/")) { prefix = prefix.substring(0, prefix.length() - 1); } return prefix; } private  PathPrefixUtil(); static String sanitize(String prefix); static String strip(HibBranch branch, String path); static boolean startsWithPrefix(HibBranch branch, String path);  }
@Test public void testSanitize() { assertEquals("", PathPrefixUtil.sanitize("")); assertEquals("/bla", PathPrefixUtil.sanitize("bla")); assertEquals("/bla", PathPrefixUtil.sanitize("bla/")); assertEquals("", PathPrefixUtil.sanitize("/")); }