pull/32/head
kunfei 5 years ago
parent 2f141c8ff8
commit 70f10e7ff5
  1. 5
      app/src/main/java/io/legado/app/help/storage/OldRule.kt
  2. 4
      app/src/main/java/io/legado/app/help/storage/Restore.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<String, String>()
var url = oldUrl
var url: String = oldUrl
var mather = headerPattern.matcher(url)
if (mather.find()) {
val header = mather.group()

@ -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"),

Loading…
Cancel
Save