From 2861a0c4b4df6ee9e5050a8908a9f8cb318fc4f3 Mon Sep 17 00:00:00 2001 From: kunfei Date: Sun, 3 Nov 2019 15:29:00 +0800 Subject: [PATCH] up --- .../io/legado/app/help/http/AjaxWebView.kt | 18 ++---------------- .../legado/app/model/analyzeRule/AnalyzeUrl.kt | 1 + 2 files changed, 3 insertions(+), 16 deletions(-) diff --git a/app/src/main/java/io/legado/app/help/http/AjaxWebView.kt b/app/src/main/java/io/legado/app/help/http/AjaxWebView.kt index 95fc361db..81d8f3099 100644 --- a/app/src/main/java/io/legado/app/help/http/AjaxWebView.kt +++ b/app/src/main/java/io/legado/app/help/http/AjaxWebView.kt @@ -10,7 +10,6 @@ import android.text.TextUtils import android.webkit.* import io.legado.app.App import java.lang.ref.WeakReference -import java.util.* class AjaxWebView { @@ -99,7 +98,6 @@ class AjaxWebView { var cookieStore: CookieStore? = null var sourceRegex: String? = null var javaScript: String? = null - private var audioSuffixList: List? = null val userAgent: String? get() = this.headerMap?.get("User-Agent") @@ -122,16 +120,6 @@ class AjaxWebView { javaScript = null } - fun getAudioSuffixList(): List? { - if (audioSuffixList == null) { - audioSuffixList = if (isSniff) { - sourceRegex?.split("\\|\\|".toRegex()) - } else { - Collections.emptyList() - } - } - return audioSuffixList - } } class HtmlWebViewClient( @@ -186,12 +174,10 @@ class AjaxWebView { ) : WebViewClient() { override fun onLoadResource(view: WebView, url: String) { - val suffixList = params.getAudioSuffixList() - for (suffix in suffixList!!) { - if (!TextUtils.isEmpty(suffix) && url.contains(suffix)) { + params.sourceRegex?.let { + if (url.matches(it.toRegex())) { handler.obtainMessage(MSG_SUCCESS, url) .sendToTarget() - break } } } diff --git a/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt b/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt index 5494d61a8..8cd4149c7 100644 --- a/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt +++ b/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt @@ -292,6 +292,7 @@ class AnalyzeUrl( suspend fun getResultByWebView(tag: String): String { val params = AjaxWebView.AjaxParams(tag) params.url = url + params.headerMap = headerMap params.requestMethod = method params.javaScript = webViewJs params.sourceRegex = sourceRegex