From 3dec19f0eecd8873a7df115343a9e63c88113e85 Mon Sep 17 00:00:00 2001 From: Horis <8674809+821938089@users.noreply.github.com> Date: Tue, 31 Dec 2024 12:24:03 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/lib/webdav/WebDav.kt | 5 ++++- app/src/main/java/io/legado/app/lib/webdav/WebDavFile.kt | 9 ++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/io/legado/app/lib/webdav/WebDav.kt b/app/src/main/java/io/legado/app/lib/webdav/WebDav.kt index de9723e7c..6f2c726e3 100644 --- a/app/src/main/java/io/legado/app/lib/webdav/WebDav.kt +++ b/app/src/main/java/io/legado/app/lib/webdav/WebDav.kt @@ -211,7 +211,10 @@ open class WebDav( .toInstant(ZoneOffset.of("+8")).toEpochMilli() } }.getOrNull() ?: 0 - val fullURL = NetworkUtils.getAbsoluteURL(baseUrl, hrefDecode) + var fullURL = NetworkUtils.getAbsoluteURL(baseUrl, hrefDecode) + if (WebDavFile.isDir(contentType, resourceType) && !fullURL.endsWith("/")) { + fullURL += "/" + } webDavFile = WebDavFile( fullURL, authorization, diff --git a/app/src/main/java/io/legado/app/lib/webdav/WebDavFile.kt b/app/src/main/java/io/legado/app/lib/webdav/WebDavFile.kt index 8ff3776aa..70b9becd6 100644 --- a/app/src/main/java/io/legado/app/lib/webdav/WebDavFile.kt +++ b/app/src/main/java/io/legado/app/lib/webdav/WebDavFile.kt @@ -16,7 +16,14 @@ class WebDavFile( ) : WebDav(urlStr, authorization) { val isDir by lazy { - contentType == "httpd/unix-directory" || resourceType.lowercase().contains("collection") + isDir(contentType, resourceType) + } + + companion object { + fun isDir(contentType: String, resourceType: String): Boolean { + return contentType == "httpd/unix-directory" + || resourceType.lowercase().contains("collection") + } } }