From: Mathieu Baudier Date: Wed, 6 Jun 2018 16:43:59 +0000 (+0200) Subject: Make relativize more robust X-Git-Tag: argeo-commons-2.1.74~20 X-Git-Url: https://git.argeo.org/?a=commitdiff_plain;h=4d9c1bd119e04fd8c21e9cb8756c97ad25faa0fc;p=lgpl%2Fargeo-commons.git Make relativize more robust --- diff --git a/org.argeo.jcr/src/org/argeo/jcr/fs/JcrPath.java b/org.argeo.jcr/src/org/argeo/jcr/fs/JcrPath.java index 8917f13a1..b75189ade 100644 --- a/org.argeo.jcr/src/org/argeo/jcr/fs/JcrPath.java +++ b/org.argeo.jcr/src/org/argeo/jcr/fs/JcrPath.java @@ -259,9 +259,12 @@ public class JcrPath implements Path { if (other.startsWith(this)) { String p1 = toString(); String p2 = other.toString(); - return new JcrPath(fs, p2.substring(p1.length(), p2.length())); + String relative = p2.substring(p1.length(), p2.length()); + if(relative.charAt(0)=='/') + relative = relative.substring(1); + return new JcrPath(fs,relative); } - throw new IllegalArgumentException(other + " cannot be realtivized against " + this); + throw new IllegalArgumentException(other + " cannot be relativized against " + this); } @Override