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' extName = 'DMZJ'
pkgNameSuffix = 'zh.dmzj' pkgNameSuffix = 'zh.dmzj'
extClass = '.Dmzj' extClass = '.Dmzj'
extVersionCode = 32 extVersionCode = 33
} }
apply from: "$rootDir/common.gradle" apply from: "$rootDir/common.gradle"

View File

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