File tree Expand file tree Collapse file tree 1 file changed +11
-7
lines changed
Expand file tree Collapse file tree 1 file changed +11
-7
lines changed Original file line number Diff line number Diff line change @@ -1131,16 +1131,20 @@ func biliWbiSign(param: String, completion: @escaping (String?) -> Void) {
11311131 func encWbi (params : [String : Any ], imgKey : String , subKey : String ) -> [String : Any ] {
11321132 var params = params
11331133 let mixinKey = getMixinKey (orig : imgKey + subKey)
1134- let currTime = round (Date ().timeIntervalSince1970 )
1134+ let currTime = Int (Date ().timeIntervalSince1970 )
11351135 params[" wts" ] = currTime
1136- params = params.sorted { $0 .key < $1 .key }.reduce (into : [: ]) { $0 [$1 .key ] = $1 .value }
1137- params = params.mapValues { value in
1136+ let query = params.sorted {
1137+ $0 .key < $1 .key
1138+ }.map { (key, value) -> String in
1139+ let stringValue: String
11381140 if let doubleValue = value as? Double , doubleValue.truncatingRemainder (dividingBy : 1 ) == 0 {
1139- return String (Int (doubleValue)).filter { ! " !'()*" .contains ($0 ) }
1141+ stringValue = String (Int (doubleValue))
1142+ } else {
1143+ stringValue = String (describing : value)
11401144 }
1141- return String ( describing : value) .filter { ! " !'()*" .contains ($0 ) }
1142- }
1143- let query = params. map { " \( $0 . key ) = \( $0 . value ) " }.joined (separator : " &" )
1145+ let filteredValue = stringValue .filter { ! " !'()*" .contains ($0 ) }
1146+ return " \( key ) = \( filteredValue ) "
1147+ }.joined (separator : " &" )
11441148 let wbiSign = calculateMD5 (string : query + mixinKey)
11451149 params[" w_rid" ] = wbiSign
11461150 return params
You can’t perform that action at this time.
0 commit comments