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:
parent
d268be8f13
commit
a7c7ed3b77
|
@ -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"
|
||||||
|
|
|
@ -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()]!!
|
||||||
|
|
Loading…
Reference in New Issue