SLING-7499: handle blank string.
diff --git a/src/main/java/org/apache/sling/resourceresolver/impl/helper/URI.java b/src/main/java/org/apache/sling/resourceresolver/impl/helper/URI.java
index 2da65cb..ec1caae 100644
--- a/src/main/java/org/apache/sling/resourceresolver/impl/helper/URI.java
+++ b/src/main/java/org/apache/sling/resourceresolver/impl/helper/URI.java
@@ -2029,8 +2029,14 @@
                 idx++;
             }
             if (idx > 0) {
-                tmp = tmp.substring(idx);
-                length -= idx;
+                if (idx < length) {
+                    tmp = tmp.substring(idx);
+                    length -= idx;
+                }
+                else {
+                    tmp = "";
+                    length = 0;
+                }
             }
         }