优化dataUri处理

pull/1713/head
kunfei 3 years ago
parent a957714de5
commit 9c02293c26
  1. 4
      app/src/main/java/io/legado/app/model/webBook/BookInfo.kt
  2. 4
      app/src/main/java/io/legado/app/model/webBook/BookList.kt
  3. 2
      app/src/main/java/io/legado/app/utils/NetworkUtils.kt

@ -127,9 +127,7 @@ object BookInfo {
Debug.log(bookSource.bookSourceUrl, "┌获取封面链接")
try {
analyzeRule.getString(infoRule.coverUrl).let {
if (it.startsWith("data:")) {
book.coverUrl = it
} else if (it.isNotEmpty()) {
if (it.isNotEmpty()) {
book.coverUrl =
NetworkUtils.getAbsoluteURL(baseUrl, it)
}

@ -229,9 +229,7 @@ object BookList {
Debug.log(bookSource.bookSourceUrl, "┌获取封面链接", log)
try {
analyzeRule.getString(ruleCoverUrl).let {
if (it.startsWith("data:")) {
searchBook.coverUrl = it
} else if (it.isNotEmpty()) {
if (it.isNotEmpty()) {
searchBook.coverUrl =
NetworkUtils.getAbsoluteURL(baseUrl, it)
}

@ -4,6 +4,7 @@ import android.net.ConnectivityManager
import android.net.NetworkCapabilities
import android.os.Build
import io.legado.app.constant.AppLog
import io.legado.app.constant.AppPattern
import okhttp3.internal.publicsuffix.PublicSuffixDatabase
import splitties.systemservices.connectivityManager
@ -110,6 +111,7 @@ object NetworkUtils {
fun getAbsoluteURL(baseURL: String?, relativePath: String): String {
if (baseURL.isNullOrEmpty()) return relativePath
if (relativePath.isAbsUrl()) return relativePath
if (relativePath.matches(AppPattern.dataUriRegex)) return relativePath
if (relativePath.startsWith("javascript")) return ""
var relativeUrl = relativePath
try {

Loading…
Cancel
Save