pull/1298/head
gedoor 4 years ago
parent 5bb5cd9bd4
commit c961d27841
  1. 28
      app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt

@ -157,7 +157,6 @@ class AnalyzeUrl(
option.method?.let { option.method?.let {
if (it.equals("POST", true)) method = RequestMethod.POST if (it.equals("POST", true)) method = RequestMethod.POST
} }
option.type?.let { type = it }
option.headers?.let { headers -> option.headers?.let { headers ->
if (headers is Map<*, *>) { if (headers is Map<*, *>) {
headers.forEach { entry -> headers.forEach { entry ->
@ -168,20 +167,19 @@ class AnalyzeUrl(
?.let { headerMap.putAll(it) } ?.let { headerMap.putAll(it) }
} }
} }
option.charset?.let { charset = it }
option.body?.let { option.body?.let {
body = if (it is String) it else GSON.toJson(it) body = if (it is String) it else GSON.toJson(it)
} }
option.webView?.let { type = option.type
if (it.toString().isNotEmpty()) { charset = option.charset
useWebView = true retry = option.retry
} useWebView = option.webView?.toString()?.isNotBlank() == true
}
webJs = option.webJs webJs = option.webJs
option.js?.let { option.js?.let { jsStr ->
evalJS(it) evalJS(jsStr, url)?.toString()?.let {
url = it
}
} }
retry = option.retry
} }
} }
headerMap[UA_NAME] ?: let { headerMap[UA_NAME] ?: let {
@ -194,10 +192,6 @@ class AnalyzeUrl(
if (pos != -1) { if (pos != -1) {
analyzeFields(url.substring(pos + 1)) analyzeFields(url.substring(pos + 1))
urlNoQuery = url.substring(0, pos) urlNoQuery = url.substring(0, pos)
} else body?.let {
if (!it.isJson()) {
analyzeFields(it)
}
} }
} }
RequestMethod.POST -> body?.let { RequestMethod.POST -> body?.let {
@ -437,13 +431,13 @@ class AnalyzeUrl(
data class UrlOption( data class UrlOption(
val method: String?, val method: String?,
val charset: String?, val charset: String?,
val webView: Any?,
val webJs: String?,
val headers: Any?, val headers: Any?,
val body: Any?, val body: Any?,
val type: String?, val type: String?,
val js: String?, val js: String?,
val retry: Int = 0 val retry: Int = 0,
val webView: Any?,
val webJs: String?,
) )
data class FetchRecord( data class FetchRecord(

Loading…
Cancel
Save