diff --git a/webdav3/client.py b/webdav3/client.py index d923bd1..7640ebc 100644 --- a/webdav3/client.py +++ b/webdav3/client.py @@ -16,10 +16,10 @@ from webdav3.exceptions import * from webdav3.urn import Urn try: - from urllib.parse import unquote, urlsplit + from urllib.parse import unquote, urlsplit, urlparse except ImportError: from urllib import unquote - from urlparse import urlsplit + from urlparse import urlsplit, urlparse __version__ = "0.2" log = logging.getLogger(__name__) @@ -958,12 +958,12 @@ class WebDavXmlUtils: :param hostname: the server hostname. :return: XML object of response for the remote resource defined by path. """ + prefix = urlparse(hostname).path try: if isinstance(content, str): content = content.encode('utf-8') tree = etree.fromstring(content) responses = tree.findall("{DAV:}response") - n_path = Urn.normalize_path(path) for resp in responses: @@ -971,6 +971,9 @@ class WebDavXmlUtils: if Urn.compare_path(n_path, href) is True: return resp + href_without_prefix = href[len(prefix):] if href.startswith(prefix) else href + if Urn.compare_path(n_path, href_without_prefix) is True: + return resp raise RemoteResourceNotFound(path) except etree.XMLSyntaxError: raise MethodNotSupported(name="is_dir", server=hostname)