Handle trailing slash for path objects

git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1765079 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/src/main/java/org/apache/sling/api/resource/path/Path.java b/src/main/java/org/apache/sling/api/resource/path/Path.java
index 6e73013..3ab8ad4 100644
--- a/src/main/java/org/apache/sling/api/resource/path/Path.java
+++ b/src/main/java/org/apache/sling/api/resource/path/Path.java
@@ -19,6 +19,7 @@
 package org.apache.sling.api.resource.path;
 
 import java.util.regex.Pattern;
+
 import javax.annotation.Nonnull;
 
 /**
@@ -48,7 +49,13 @@
      * @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)));