From db1f2666e8c6148b6ed45d7895ca77697adb24b5 Mon Sep 17 00:00:00 2001 From: rfc2822 Date: Wed, 16 Oct 2013 00:09:29 +0200 Subject: [PATCH] fixes issue #11 --- .../bitfire/davdroid/webdav/WebDavCollection.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/at/bitfire/davdroid/webdav/WebDavCollection.java b/src/at/bitfire/davdroid/webdav/WebDavCollection.java index c373b282..8f1c5d30 100644 --- a/src/at/bitfire/davdroid/webdav/WebDavCollection.java +++ b/src/at/bitfire/davdroid/webdav/WebDavCollection.java @@ -13,6 +13,7 @@ import java.io.IOException; import java.io.InputStream; import java.io.StringWriter; import java.net.URI; +import java.net.URISyntaxException; import java.util.ArrayList; import java.util.LinkedList; import java.util.List; @@ -169,7 +170,7 @@ public class WebDavCollection extends WebDavResource { WebDavResource referenced = null; - if (location.equals(location.resolve(href))) { + if (sameURL(location, location.resolve(href))) { // response is about this property referenced = this; @@ -226,4 +227,15 @@ public class WebDavCollection extends WebDavResource { } this.members = members; } + + + private boolean sameURL(URI a, URI b) { + try { + a = new URI(a.getScheme(), null, a.getHost(), a.getPort(), a.getPath(), a.getQuery(), a.getFragment()); + b = new URI(b.getScheme(), null, b.getHost(), b.getPort(), b.getPath(), b.getQuery(), b.getFragment()); + return a.equals(b); + } catch (URISyntaxException e) { + return false; + } + } }