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实现文件下载
*/
fun downloadFile(content: String, url: String): String {
val type = AnalyzeUrl(url).type ?: return "type为空,未下载"
val zipPath = FileUtils.getPath(
FileUtils.createFolderIfNotExist(FileUtils.getCachePath()),
"${MD5Utils.md5Encode16(url)}.zip"
"${MD5Utils.md5Encode16(url)}.${type}"
)
FileUtils.deleteFile(zipPath)
val zipFile = FileUtils.createFileIfNotExist(zipPath)
@ -137,14 +138,18 @@ interface JsExtensions {
* js实现解码,不能删
*/
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? {
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)
}

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

Loading…
Cancel
Save