From abc04548c49fc8c152172b800591f3d781e91e10 Mon Sep 17 00:00:00 2001 From: Svend Date: Fri, 3 Apr 2020 09:38:08 +0800 Subject: [PATCH 1/2] Fixed: Custom host can cause problems when the URL returned does not have a complete schema. --- uPic/Models/Custom/CustomUploader.swift | 13 ++++++++----- uPic/Models/HostConfig.swift | 13 ------------- 2 files changed, 8 insertions(+), 18 deletions(-) diff --git a/uPic/Models/Custom/CustomUploader.swift b/uPic/Models/Custom/CustomUploader.swift index 4064c68..1e15b18 100644 --- a/uPic/Models/Custom/CustomUploader.swift +++ b/uPic/Models/Custom/CustomUploader.swift @@ -140,17 +140,20 @@ class CustomUploader: BaseUploader { }.responseJSON(completionHandler: { response -> Void in switch response.result { case .success(let value): - debugPrint(value) let json = JSON(value) - var retUrl = CustomHostUtil.parseResultUrl(json, config.resultPath ?? "") - if retUrl.isEmpty { + var retUrlPath = CustomHostUtil.parseResultUrl(json, config.resultPath ?? "") + if retUrlPath.isEmpty { super.faild(errorMsg: "Did not get the file URL".localized) return } if !domain.isEmpty { - retUrl = "\(domain)/\(retUrl)" + if retUrlPath.hasPrefix("/") { + retUrlPath = "\(domain)\(retUrlPath)" + } else { + retUrlPath = "\(domain)/\(retUrlPath)" + } } - super.completed(url: "\(retUrl)\(suffix)", retData, fileUrl, nil) + super.completed(url: "\(retUrlPath)\(suffix)", retData, fileUrl, nil) case .failure(let error): super.faild(errorMsg: error.localizedDescription) } diff --git a/uPic/Models/HostConfig.swift b/uPic/Models/HostConfig.swift index f54cf72..e3da6e4 100644 --- a/uPic/Models/HostConfig.swift +++ b/uPic/Models/HostConfig.swift @@ -158,19 +158,6 @@ class HostConfig: NSObject, Codable { self.setValue(saveKeyPath, forKey: "saveKeyPath") } } - - if self.containsKey(key: "domain") { - var domain = self.value(forKey: "domain") as! String - if domain.hasSuffix("/") { - domain.removeLast() - self.setValue(domain, forKey: "domain") - } - - if (!domain.isEmpty && !domain.hasPrefix("http://") && !domain.hasPrefix("https://")) { - domain = "http://\(domain)" - self.setValue(domain, forKey: "domain") - } - } } } From 3dffe676fa5bb5f2c7d1f3eabf7e26e785f2415e Mon Sep 17 00:00:00 2001 From: Svend Date: Fri, 3 Apr 2020 09:39:43 +0800 Subject: [PATCH 2/2] Releasing v0.18.2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Fixed: Custom host failed to upload in some cases. - Support Chevereto!,[tutorial addresses](https://blog.svend.cc/upic/tutorials/chevereto/cn/) - Fixed: Custom host can cause problems when the URL returned does not have a complete schema. fixes 90 --- uPic.xcodeproj/project.pbxproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/uPic.xcodeproj/project.pbxproj b/uPic.xcodeproj/project.pbxproj index 5355838..2b620f6 100644 --- a/uPic.xcodeproj/project.pbxproj +++ b/uPic.xcodeproj/project.pbxproj @@ -1227,7 +1227,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Manual; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 20200402; + CURRENT_PROJECT_VERSION = 20200403; DEVELOPMENT_TEAM = W863J6W8DZ; ENABLE_HARDENED_RUNTIME = YES; INFOPLIST_FILE = "$(SRCROOT)/uPic/Supporting Files/Info.plist"; @@ -1257,7 +1257,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Manual; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 20200402; + CURRENT_PROJECT_VERSION = 20200403; DEVELOPMENT_TEAM = W863J6W8DZ; ENABLE_HARDENED_RUNTIME = YES; INFOPLIST_FILE = "$(SRCROOT)/uPic/Supporting Files/Info.plist";