From 2bf6a4b39c412812d0a75616b463d7aa40ce70eb Mon Sep 17 00:00:00 2001 From: Xwite <1797350009@qq.com> Date: Wed, 1 Jun 2022 08:28:07 +0800 Subject: [PATCH] fix(EpubFile/parseFirstPage): parse all contents fix #1932 --- .../java/io/legado/app/model/localBook/EpubFile.kt | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/io/legado/app/model/localBook/EpubFile.kt b/app/src/main/java/io/legado/app/model/localBook/EpubFile.kt index f8123abac..a454da48d 100644 --- a/app/src/main/java/io/legado/app/model/localBook/EpubFile.kt +++ b/app/src/main/java/io/legado/app/model/localBook/EpubFile.kt @@ -139,10 +139,10 @@ class EpubFile(var book: Book) { * content src text/000001.html(当前章节) - * content src text/000001.html#toc_id_x (下一章节) */ - if (!nextUrl.isNullOrBlank() && res.href == nextUrl!!.substringBeforeLast("#")) break + if (res.href == nextUrl?.substringBeforeLast("#")) break } else if (isChapter) { // fix 最后一章存在多个html时 内容缺失 - if (!nextUrl.isNullOrBlank() && res.href == nextUrl.substringBeforeLast("#")) { + if (res.href == nextUrl?.substringBeforeLast("#")) { break } elements.add(getBody(res, startFragmentId, endFragmentId)) @@ -276,8 +276,12 @@ class EpubFile(var book: Book) { while (i < contents.size) { val content = contents[i] if (!content.mediaType.toString().contains("htm")) continue - /*检索到第一章href停止*/ - if (refs[0].completeHref == content.href) break + /** + * 检索到第一章href停止 + * completeHref可能有fragment(#id) 必须去除 + * fix https://github.com/gedoor/legado/issues/1932 + */ + if (refs[0].completeHref.substringBeforeLast("#") == content.href) break val chapter = BookChapter() var title = content.title if (TextUtils.isEmpty(title)) {