update java.getCookie

java.getCookie("http://baidu.com") return user=test;pwd=123
java.getCookie("http://baidu.com", "user") reurn test
pull/440/head
AndyBernie 4 years ago
parent 012d0c9d3e
commit deeeaa3b53
  1. 2
      app/src/main/assets/updateLog.md
  2. 10
      app/src/main/java/io/legado/app/help/JsExtensions.kt
  3. 2
      app/src/main/java/io/legado/app/help/http/CookieStore.kt

@ -6,7 +6,7 @@
**2020/10/23**
* 修复选择错误的bug
* 修复长图最后一张不能滚动的bug
* js添加java.getCookie(sourceUrl)来获取登录后的cookie by [AndyBernie](https://github.com/AndyBernie)
* js添加java.getCookie(sourceUrl:String, key:String ?=null)来获取登录后的cookie by [AndyBernie](https://github.com/AndyBernie)
* 修复简繁转换没有处理标题
**2020/10/21**

@ -123,8 +123,14 @@ interface JsExtensions {
/**
*js实现读取cookie
*/
fun getCookie(tag: String): String {
return CookieStore.getCookie(tag)
fun getCookie(tag: String, key: String? = null): String {
val cookie = CookieStore.getCookie(tag)
val cookieMap = CookieStore.cookieToMap(cookie)
return if (key != null) {
cookieMap.get(key) ?: ""
} else {
cookie
}
}
/**

@ -43,7 +43,7 @@ object CookieStore : CookiePersistor {
App.db.cookieDao().delete(NetworkUtils.getSubDomain(url))
}
private fun cookieToMap(cookie: String): MutableMap<String, String> {
fun cookieToMap(cookie: String): MutableMap<String, String> {
val cookieMap = mutableMapOf<String, String>()
if (cookie.isBlank()) {
return cookieMap

Loading…
Cancel
Save