DMZJ: fix chapter name format (#13697)

* DMZJ: fix chapter name format

* make regex private
This commit is contained in:
stevenyomi 2022-10-04 05:35:12 +08:00 committed by GitHub
parent f6a916634b
commit 9b7e28848b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 7 deletions

View File

@ -6,7 +6,7 @@ ext {
extName = 'DMZJ'
pkgNameSuffix = 'zh.dmzj'
extClass = '.Dmzj'
extVersionCode = 32
extVersionCode = 33
}
apply from: "$rootDir/common.gradle"

View File

@ -30,13 +30,13 @@ fun parseStatus(status: String): Int = when (status) {
else -> SManga.UNKNOWN
}
private val chapterNameRegex = Regex("""(?:连载版?)?(\d[.\d]*)([话卷])?""")
fun String.formatChapterName(): String {
val replaced = removePrefix("连载")
if (!replaced[0].isDigit()) return replaced
return when (replaced.last()) {
'话', '卷' -> "$replaced"
else -> replaced
}
val match = chapterNameRegex.matchEntire(this) ?: return this
val (number, optionalType) = match.destructured
val type = optionalType.ifEmpty { "" }
return "$number$type"
}
fun String.toHttps() = "https:" + substringAfter(':')