kwin commented on code in PR #94:
URL:
https://github.com/apache/sling-org-apache-sling-api/pull/94#discussion_r4561237875
##########
src/main/java/org/apache/sling/api/resource/path/PathBuilder.java:
##########
@@ -68,12 +78,21 @@ public PathBuilder append(final String path) {
}
/**
- * Returns the path
+ * Returns the normalized path without changing the accumulated fragments.
+ * Dot segments are resolved, duplicate slashes are collapsed, and trailing
+ * slashes are removed except for the root path.
*
- * @return the path
+ * @return the normalized absolute path
+ * @throws IllegalArgumentException if the path cannot be normalized, for
example
+ * because it traverses above root
*/
@Override
public String toString() {
- return sb.toString();
+ final String path = sb.toString();
+ final String normalizedPath = ResourceUtil.normalize(path);
+ if (normalizedPath == null) {
+ throw new IllegalArgumentException("Path cannot be normalized");
Review Comment:
Sounds good, however for builder patterns I would use the method prefix
`build...` instead of `to...`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]