iosswiftkingfisher

URL is not valid to support in Kingfisher


URL is not supported in Kingfisher that URL contains an Arabic string. Please check URL "/image/cache/catalog/NEE/150ذهبي%20جديدة-500x500.jpg".

I have tried to debug in the library, It will returns resources empty and redirect to the below code.

guard let resource = resource else { 
  self.placeholder = placeholder 
  setWebURL(nil) 
  completionHandler?(nil, nil, .none, nil) 
  return .empty 
}

How can I prevent this issue?

Notes


Solution

  • I have resolved it after encoding URL.

    Swift 4.0

    For Example:

    let image_url = "/image/cache/catalog/NEE/150ذهبي%20جديدة-500x500.jpg".addingPercentEncoding(withAllowedCharacters:CharacterSet.urlQueryAllowed)
    

    Notes - I have mentioned Kingfisher over here because kingfisher "Resources" does not support URL if its name in English. So, we need to pass encoded URL.