From c380b113c649798fc1cd284150514ab569aaa734 Mon Sep 17 00:00:00 2001 From: gedoor Date: Mon, 18 Oct 2021 10:50:05 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/legado/app/service/HttpReadAloudService.kt | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/io/legado/app/service/HttpReadAloudService.kt b/app/src/main/java/io/legado/app/service/HttpReadAloudService.kt index f0e11dc90..53dd2c86b 100644 --- a/app/src/main/java/io/legado/app/service/HttpReadAloudService.kt +++ b/app/src/main/java/io/legado/app/service/HttpReadAloudService.kt @@ -129,15 +129,16 @@ class HttpReadAloudService : BaseReadAloudService(), headerMapF = httpTts.getHeaderMap(true) ) var response = analyzeUrl.getResponseAwait() - httpTts.loginCheckJs?.let { checkJs -> - if (checkJs.isNotBlank()) { - response = analyzeUrl.evalJS(checkJs, response) as Response - } + httpTts.loginCheckJs?.takeIf { checkJs -> + checkJs.isNotBlank() + }?.let { checkJs -> + response = analyzeUrl.evalJS(checkJs, response) as Response } - val contentTypeRegex = httpTts.contentType - if (!contentTypeRegex.isNullOrBlank()) { + httpTts.contentType?.takeIf { ct -> + ct.isNotBlank() + }?.let { ct -> response.headers["Content-Type"]?.let { contentType -> - if (!contentType.matches(contentTypeRegex.toRegex())) { + if (!contentType.matches(ct.toRegex())) { throw NoStackTraceException(response.body!!.string()) } }