pull/464/head
飞鸟队员 4 years ago
parent 9fc93945c5
commit c9887ffe1b
  1. 13
      app/src/main/java/io/legado/app/help/JsExtensions.kt
  2. 2
      app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt

@ -46,9 +46,10 @@ interface JsExtensions {
* js实现文件下载 * js实现文件下载
*/ */
fun downloadFile(content: String, url: String): String { fun downloadFile(content: String, url: String): String {
val type = AnalyzeUrl(url).type ?: return "type为空,未下载"
val zipPath = FileUtils.getPath( val zipPath = FileUtils.getPath(
FileUtils.createFolderIfNotExist(FileUtils.getCachePath()), FileUtils.createFolderIfNotExist(FileUtils.getCachePath()),
"${MD5Utils.md5Encode16(url)}.zip" "${MD5Utils.md5Encode16(url)}.${type}"
) )
FileUtils.deleteFile(zipPath) FileUtils.deleteFile(zipPath)
val zipFile = FileUtils.createFileIfNotExist(zipPath) val zipFile = FileUtils.createFileIfNotExist(zipPath)
@ -137,14 +138,18 @@ interface JsExtensions {
* js实现解码,不能删 * js实现解码,不能删
*/ */
fun base64Decode(str: String): String { fun base64Decode(str: String): String {
return EncoderUtils.base64Decode(str) return EncoderUtils.base64Decode(str, Base64.NO_WRAP)
}
fun base64Decode(str: String, flags: Int): String {
return EncoderUtils.base64Decode(str, flags)
} }
fun base64Encode(str: String): String? { fun base64Encode(str: String): String? {
return EncoderUtils.base64Encode(str) return EncoderUtils.base64Encode(str, Base64.NO_WRAP)
} }
fun base64Encode(str: String, flags: Int = Base64.NO_WRAP): String? { fun base64Encode(str: String, flags: Int): String? {
return EncoderUtils.base64Encode(str, flags) return EncoderUtils.base64Encode(str, flags)
} }

@ -52,6 +52,7 @@ class AnalyzeUrl(
var url: String = "" var url: String = ""
val headerMap = HashMap<String, String>() val headerMap = HashMap<String, String>()
var body: String? = null var body: String? = null
var type: String? = null
private lateinit var urlHasQuery: String private lateinit var urlHasQuery: String
private var queryStr: String? = null private var queryStr: String? = null
private val fieldMap = LinkedHashMap<String, String>() private val fieldMap = LinkedHashMap<String, String>()
@ -60,7 +61,6 @@ class AnalyzeUrl(
private var method = RequestMethod.GET private var method = RequestMethod.GET
private val splitUrlRegex = Regex(",\\s*(?=\\{)") private val splitUrlRegex = Regex(",\\s*(?=\\{)")
private var proxy: String? = null private var proxy: String? = null
private var type: String? = null
init { init {
baseUrl = baseUrl.split(splitUrlRegex, 1)[0] baseUrl = baseUrl.split(splitUrlRegex, 1)[0]

Loading…
Cancel
Save