修复一个崩溃bug

pull/352/head
gedoor 4 years ago
parent 744ed586db
commit d034f99efb
  1. 12
      app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt

@ -192,9 +192,8 @@ class AnalyzeUrl(
option?.let { _ -> option?.let { _ ->
option.method?.let { if (it.equals("POST", true)) method = RequestMethod.POST } option.method?.let { if (it.equals("POST", true)) method = RequestMethod.POST }
option.headers?.let { headers -> option.headers?.let { headers ->
if (headers is Map<*, *>) { (headers as? Map<*, *>)?.forEach { key, value ->
@Suppress("unchecked_cast") headerMap[key.toString()] = value.toString()
headerMap.putAll(headers as Map<out String, String>)
} }
if (headers is String) { if (headers is String) {
GSON.fromJsonObject<Map<String, String>>(headers) GSON.fromJsonObject<Map<String, String>>(headers)
@ -242,7 +241,6 @@ class AnalyzeUrl(
/** /**
* 解析QueryMap * 解析QueryMap
*/ */
@Throws(Exception::class)
private fun analyzeFields(fieldsTxt: String) { private fun analyzeFields(fieldsTxt: String) {
queryStr = fieldsTxt queryStr = fieldsTxt
val queryS = fieldsTxt.splitNotBlank("&") val queryS = fieldsTxt.splitNotBlank("&")
@ -266,7 +264,6 @@ class AnalyzeUrl(
/** /**
* 执行JS * 执行JS
*/ */
@Throws(Exception::class)
private fun evalJS( private fun evalJS(
jsStr: String, jsStr: String,
result: Any?, result: Any?,
@ -288,7 +285,6 @@ class AnalyzeUrl(
return SCRIPT_ENGINE.eval(jsStr, bindings) return SCRIPT_ENGINE.eval(jsStr, bindings)
} }
@Throws(Exception::class)
fun getResponse(tag: String): Call<String> { fun getResponse(tag: String): Call<String> {
val cookie = CookieStore.getCookie(tag) val cookie = CookieStore.getCookie(tag)
if (cookie.isNotEmpty()) { if (cookie.isNotEmpty()) {
@ -315,7 +311,6 @@ class AnalyzeUrl(
} }
} }
@Throws(Exception::class)
suspend fun getResponseAwait( suspend fun getResponseAwait(
tag: String, tag: String,
jsStr: String? = null, jsStr: String? = null,
@ -388,7 +383,6 @@ class AnalyzeUrl(
return Res(NetworkUtils.getUrl(res), res.body()) return Res(NetworkUtils.getUrl(res), res.body())
} }
@Throws(Exception::class)
fun getImageBytes(tag: String): ByteArray? { fun getImageBytes(tag: String): ByteArray? {
val cookie = CookieStore.getCookie(tag) val cookie = CookieStore.getCookie(tag)
if (cookie.isNotEmpty()) { if (cookie.isNotEmpty()) {
@ -401,7 +395,6 @@ class AnalyzeUrl(
} }
} }
@Throws(Exception::class)
suspend fun getResponseBytes(tag: String? = null): ByteArray? { suspend fun getResponseBytes(tag: String? = null): ByteArray? {
if (tag != null) { if (tag != null) {
val cookie = CookieStore.getCookie(tag) val cookie = CookieStore.getCookie(tag)
@ -431,7 +424,6 @@ class AnalyzeUrl(
return response.body() return response.body()
} }
@Throws(Exception::class)
fun getGlideUrl(): Any? { fun getGlideUrl(): Any? {
var glideUrl: Any = urlHasQuery var glideUrl: Any = urlHasQuery
if (headerMap.isNotEmpty()) { if (headerMap.isNotEmpty()) {

Loading…
Cancel
Save