cubari: prevent `NullPointerException` when key is 084 and chapter_number is 84 (#15418)

* cubari: fix

prevent `NullPointerException` when chapters.key is 084 and chapter.chapter_number is 84

* bump version

* simplify by using mapKeys
This commit is contained in:
mobi2002 2023-02-20 23:15:11 +05:00 committed by GitHub
parent d268be8f13
commit a7c7ed3b77
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 2 deletions

View File

@ -6,7 +6,7 @@ ext {
extName = 'Cubari' extName = 'Cubari'
pkgNameSuffix = "all.cubari" pkgNameSuffix = "all.cubari"
extClass = '.CubariFactory' extClass = '.CubariFactory'
extVersionCode = 17 extVersionCode = 18
} }
apply from: "$rootDir/common.gradle" apply from: "$rootDir/common.gradle"

View File

@ -183,7 +183,10 @@ open class Cubari(override val lang: String) : HttpSource() {
val groupMap = groups.entries.associateBy({ it.value.jsonPrimitive.content.ifEmpty { "default" } }, { it.key }) val groupMap = groups.entries.associateBy({ it.value.jsonPrimitive.content.ifEmpty { "default" } }, { it.key })
val chapterScanlator = chapter.scanlator ?: "default" // workaround for "" as group causing NullPointerException (#13772) val chapterScanlator = chapter.scanlator ?: "default" // workaround for "" as group causing NullPointerException (#13772)
val chapters = jsonObj["chapters"]!!.jsonObject // prevent NullPointerException when chapters.key is 084 and chapter.chapter_number is 84
val chapters = jsonObj["chapters"]!!.jsonObject.mapKeys {
it.key.replace(Regex("^0+(?!$)"), "")
}
val pages = if (chapters[chapter.chapter_number.toString()] != null) { val pages = if (chapters[chapter.chapter_number.toString()] != null) {
chapters[chapter.chapter_number.toString()]!! chapters[chapter.chapter_number.toString()]!!