in src/main/java/org/apache/sling/api/resource/path/Path.java [57:90]
public Path(@NotNull final String path) {
if (path.equals("/")) {
this.path = "/";
} else if (path.endsWith("/")) {
this.path = path.substring(0, path.length() - 1);
} else {
this.path = path;
}
if (this.path.startsWith(GLOB_PREFIX)) {
final String patternPath = path.substring(GLOB_PREFIX.length());
this.isPattern = true;
this.regexPattern = Pattern.compile(toRegexPattern(patternPath));
int lastSlash = 0;
int pos = 1;
while (patternPath.length() > pos) {
final char c = patternPath.charAt(pos);
if (c == '/') {
lastSlash = pos;
} else if (c == '*') {
break;
}
pos++;
}
this.prefix = (pos == patternPath.length() ? patternPath : patternPath.substring(0, lastSlash + 1));
} else {
this.isPattern = false;
this.regexPattern = null;
this.prefix = this.path.equals("/") ? "/" : this.path.concat("/");
}
if (!this.prefix.startsWith("/")) {
throw new IllegalArgumentException("Path must be absolute: " + path);
}
}