in src/main/java/org/apache/sling/api/resource/ResourceUtil.java [109:122]
private static String removeTrailingSlashes(@NotNull final String path) {
int endPos = path.length() - 1;
while (endPos >= 0 && path.charAt(endPos) == '/') {
endPos--;
}
if (endPos == path.length() - 1) {
return path;
}
// only slashes, just return one
if (endPos == -1) {
return "/";
}
return path.substring(0, endPos + 1);
}