Author: cziegeler
Date: Sat Oct 15 14:45:01 2016
New Revision: 1765079

URL: http://svn.apache.org/viewvc?rev=1765079&view=rev
Log:
Handle trailing slash for path objects

Modified:
    
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/path/Path.java

Modified: 
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/path/Path.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/path/Path.java?rev=1765079&r1=1765078&r2=1765079&view=diff
==============================================================================
--- 
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/path/Path.java
 (original)
+++ 
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/path/Path.java
 Sat Oct 15 14:45:01 2016
@@ -19,6 +19,7 @@
 package org.apache.sling.api.resource.path;
 
 import java.util.regex.Pattern;
+
 import javax.annotation.Nonnull;
 
 /**
@@ -48,7 +49,13 @@ public class Path implements Comparable<
      * @param path the resource path or a glob pattern.
      */
     public Path(@Nonnull final String path) {
-        this.path = path;
+        if ( path.equals("/") ) {
+            this.path = "/";
+        } else if ( path.endsWith("/") ) {
+            this.path = path.substring(0, path.length() - 1);
+        } else {
+            this.path = path;
+        }
         if (path.startsWith(GLOB_PREFIX)) {
             isPattern = true;
             regexPattern = Pattern.compile(toRegexPattern(path.substring(5)));


Reply via email to