diff --git a/app/src/main/java/io/legado/app/web/controller/BookshelfController.kt b/app/src/main/java/io/legado/app/web/controller/BookshelfController.kt index 2d0003879..6bae8f8aa 100644 --- a/app/src/main/java/io/legado/app/web/controller/BookshelfController.kt +++ b/app/src/main/java/io/legado/app/web/controller/BookshelfController.kt @@ -21,7 +21,7 @@ class BookshelfController { } fun getChapterList(parameters: Map>): ReturnData { - val bookUrl = parameters["url"]?.get(0) + val bookUrl = parameters["url"]?.getOrNull(0) val returnData = ReturnData() if (bookUrl.isNullOrEmpty()) { return returnData.setErrorMsg("参数url不能为空,请指定书籍地址") @@ -31,8 +31,8 @@ class BookshelfController { } fun getBookContent(parameters: Map>): ReturnData { - val bookUrl = parameters["url"]?.get(0) - val index = parameters["index"]?.get(0)?.toInt() + val bookUrl = parameters["url"]?.getOrNull(0) + val index = parameters["index"]?.getOrNull(0)?.toInt() val returnData = ReturnData() if (bookUrl.isNullOrEmpty()) { return returnData.setErrorMsg("参数url不能为空,请指定书籍地址") diff --git a/app/src/main/java/io/legado/app/web/controller/SourceController.kt b/app/src/main/java/io/legado/app/web/controller/SourceController.kt index 7eff59105..cb066ddc8 100644 --- a/app/src/main/java/io/legado/app/web/controller/SourceController.kt +++ b/app/src/main/java/io/legado/app/web/controller/SourceController.kt @@ -58,7 +58,7 @@ class SourceController { } fun getSource(parameters: Map>): ReturnData { - val url = parameters["url"]?.get(0) + val url = parameters["url"]?.getOrNull(0) val returnData = ReturnData() if (url.isNullOrEmpty()) { return returnData.setErrorMsg("参数url不能为空,请指定书源地址")