From 70f10e7ff57455908bb25a0688c1ef4a8ae65315 Mon Sep 17 00:00:00 2001 From: kunfei Date: Thu, 25 Jul 2019 19:34:49 +0800 Subject: [PATCH] up --- app/src/main/java/io/legado/app/help/storage/OldRule.kt | 5 +++-- app/src/main/java/io/legado/app/help/storage/Restore.kt | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/io/legado/app/help/storage/OldRule.kt b/app/src/main/java/io/legado/app/help/storage/OldRule.kt index e8c064f7c..27738806c 100644 --- a/app/src/main/java/io/legado/app/help/storage/OldRule.kt +++ b/app/src/main/java/io/legado/app/help/storage/OldRule.kt @@ -7,9 +7,10 @@ object OldRule { private val headerPattern = Pattern.compile("@Header:\\{.+?\\}", Pattern.CASE_INSENSITIVE) private val jsPattern = Pattern.compile("\\{\\{.+?\\}\\}", Pattern.CASE_INSENSITIVE) - fun toNewUrl(oldUrl: String): String { + fun toNewUrl(oldUrl: String?): String? { + if (oldUrl == null) return null val map = HashMap() - var url = oldUrl + var url: String = oldUrl var mather = headerPattern.matcher(url) if (mather.find()) { val header = mather.group() diff --git a/app/src/main/java/io/legado/app/help/storage/Restore.kt b/app/src/main/java/io/legado/app/help/storage/Restore.kt index 264e646c2..169da979d 100644 --- a/app/src/main/java/io/legado/app/help/storage/Restore.kt +++ b/app/src/main/java/io/legado/app/help/storage/Restore.kt @@ -107,7 +107,7 @@ object Restore { source.loginUrl = jsonItem.readString("loginUrl") source.bookUrlPattern = jsonItem.readString("ruleBookUrlPattern") val searchRule = SearchRule( - searchUrl = jsonItem.readString("ruleSearchUrl"), + searchUrl = OldRule.toNewUrl(jsonItem.readString("ruleSearchUrl")), bookList = jsonItem.readString("ruleSearchList"), name = jsonItem.readString("ruleSearchName"), author = jsonItem.readString("ruleSearchAuthor"), @@ -119,7 +119,7 @@ object Restore { ) source.ruleSearch = GSON.toJson(searchRule) val exploreRule = ExploreRule( - exploreUrl = jsonItem.readString("ruleFindUrl"), + exploreUrl = OldRule.toNewUrl(jsonItem.readString("ruleFindUrl")), bookList = jsonItem.readString("ruleFindList"), name = jsonItem.readString("ruleFindName"), author = jsonItem.readString("ruleFindAuthor"),