File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed
library/src/main/java/com/lagradost/nicehttp Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -135,13 +135,18 @@ fun OkHttpClient.Builder.ignoreAllSSLErrors(): OkHttpClient.Builder {
135
135
136
136
137
137
fun Headers.getCookies (cookieKey : String ): Map <String , String > {
138
+ // Get a list of cookie strings
139
+ // set-cookie: name=value; name2=value2 -----> [name=value, name2=value2]
138
140
val cookieList =
139
- this .filter { it.first.equals(cookieKey, ignoreCase = true ) }
140
- .getOrNull(0 )?.second?.split(" ;" )
141
- return cookieList?.associate {
141
+ this .filter { it.first.equals(cookieKey, ignoreCase = true ) }.map {
142
+ it.second.split(" ;" )
143
+ }.flatten()
144
+
145
+ // [name=value, name2=value2] -----> mapOf(name to value, name2 to value2)
146
+ return cookieList.associate {
142
147
val split = it.split(" =" )
143
148
(split.getOrNull(0 )?.trim() ? : " " ) to (split.getOrNull(1 )?.trim() ? : " " )
144
- }? .filter { it.key.isNotBlank() && it.value.isNotBlank() } ? : mapOf ()
149
+ }.filter { it.key.isNotBlank() && it.value.isNotBlank() }
145
150
}
146
151
147
152
You can’t perform that action at this time.
0 commit comments