Skip to content

Commit

Permalink
Fix invalid image parameter crash
Browse files Browse the repository at this point in the history
Resolves: #351
Resolves: #340
  • Loading branch information
justin-stephenson committed May 17, 2024
1 parent 1384c22 commit 4d07aea
Showing 1 changed file with 23 additions and 21 deletions.
44 changes: 23 additions & 21 deletions FreeOTP/ImageDownloader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -88,30 +88,32 @@ class ImageDownloader : NSObject {
}

func fromURL(_ url: URL, _ iv: UIImageView, completion: @escaping (UIImage) -> Void) {
switch url.scheme! {
case "file":
if let img = UIImage(contentsOfFile: url.path) {
return completion(img)
}
if let scheme = url.scheme {
switch scheme {
case "file":
if let img = UIImage(contentsOfFile: url.path) {
return completion(img)
}

case "assets-library":
return fromALAsset(url, completion: completion)
case "assets-library":
return fromALAsset(url, completion: completion)

case "http":
fallthrough
case "https":
iv.sd_setImage(with: url, placeholderImage: self.DEFAULT,
completed: { (image, error, cacheType, url) in
if let image {
completion(image)
}
})
return
default:
break
}

case "http":
fallthrough
case "https":
iv.sd_setImage(with: url, placeholderImage: self.DEFAULT,
completed: { (image, error, cacheType, url) in
if let image {
completion(image)
}
})
return
default:
break
return completion(DEFAULT)
}

return completion(DEFAULT)
}

func fromURI(_ uri: String?, _ iv: UIImageView, completion: @escaping (UIImage) -> Void) {
Expand Down

0 comments on commit 4d07aea

Please sign in to comment.