瀏覽代碼

Merge pull request #2255 from onevcat/freezy7-ext-fix

Freezy7 ext fix
Wei Wang 1 年之前
父節點
當前提交
5cd6819f3d
共有 2 個文件被更改,包括 9 次插入8 次删除
  1. 8 7
      Sources/Utility/String+MD5.swift
  2. 1 1
      Tests/KingfisherTests/DiskStorageTests.swift

+ 8 - 7
Sources/Utility/String+MD5.swift

@@ -49,15 +49,16 @@ extension KingfisherWrapper where Base == String {
     }
 
     var ext: String? {
-        var ext = ""
-        if let index = base.lastIndex(of: ".") {
-            let extRange = base.index(index, offsetBy: 1)..<base.endIndex
-            ext = String(base[extRange])
-        }
-        guard let firstSeg = ext.split(separator: "@").first else {
+        guard let firstSeg = base.split(separator: "@").first else {
             return nil
         }
-        return firstSeg.count > 0 ? String(firstSeg) : nil
+        
+        var ext = ""
+        if let index = firstSeg.lastIndex(of: ".") {
+            let extRange = firstSeg.index(index, offsetBy: 1)..<firstSeg.endIndex
+            ext = String(firstSeg[extRange])
+        }
+        return ext.count > 0 ? ext : nil
     }
 }
 

+ 1 - 1
Tests/KingfisherTests/DiskStorageTests.swift

@@ -213,7 +213,7 @@ class DiskStorageTests: XCTestCase {
     
     func testConfigUsesHashedFileNameWithAutoExtAndProcessor() {
         // The key of an image with processor will be as this format.
-        let key = "test.jpeg@abc"
+        let key = "test.jpeg@com.onevcat.Kingfisher.DownsamplingImageProcessor"
         
         // hashed fileName
         storage.config.usesHashedFileName = true