URLUtils { static public String getParentPath(String path) { if (path == null || path.isEmpty() || path.equals("/")) { return path; } int lastSlashPos = path.lastIndexOf('/'); if (lastSlashPos > 0) { return path.substring(0, lastSlashPos); } else if (lastSlashPos == 0) { return "/"; } else { return ""; } }  static String removeTrailingSlashes(String s); static String decodeQueryString(String qs); static String getParentPath(String path); static String getPrefixUrl(HttpServerExchange exchange); static String getQueryStringRemovingParams(HttpServerExchange exchange, String... paramsToRemove); static String getIdString(BsonValue id);  }
@Test public void testGetParentPath() { String path = "/a/b/c/d"; String expResult = "/a/b/c"; String result = URLUtils.getParentPath(path); assertEquals(expResult, result); }