Skip to content

Commit

Permalink
#29 参数过滤bug
Browse files Browse the repository at this point in the history
  • Loading branch information
mengqingzheng committed Mar 22, 2022
1 parent f15a902 commit 1c19b95
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
4 changes: 3 additions & 1 deletion Example/DaisyNetExample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -365,13 +365,15 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = A5NPR6GCJJ;
DEVELOPMENT_TEAM = "";
INFOPLIST_FILE = DaisyNetExample/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = MQZHot.DaisyNetExample;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_OBJC_BRIDGING_HEADER = "";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0;
Expand Down
20 changes: 14 additions & 6 deletions Source/CacheKey.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,20 @@ import Foundation

/// 将参数字典转换成字符串后md5
func cacheKey(_ url: String, _ params: [String: Any]?, _ dynamicParams: [String: Any]?) -> String {
/// c参数重复, `params`中过滤掉`dynamicParams`中的参数
if let filterParams = params?.filter({ key, _ -> Bool in
dynamicParams?.contains(where: { key1, _ -> Bool in
key != key1
}) ?? false
}) {
/// #29 参数过滤bug
/// 参数重复, `params`中过滤掉`dynamicParams`中的参数
let params = params ?? [:]
let dynamicParams = dynamicParams ?? [:]
var filterParams: [String: Any] = [:]

for param in params {
let commonParam = dynamicParams.first(where: { $0.key == param.key })
if commonParam == nil {
filterParams[param.key] = param.value
}
}

if filterParams.keys.count > 0 {
let str = "\(url)" + "\(sort(filterParams))"
return MD5(str)
} else {
Expand Down

0 comments on commit 1c19b95

Please sign in to comment.