Skip to content

Commit

Permalink
Merge pull request #10 from claygarrett/master
Browse files Browse the repository at this point in the history
Fix crash caused by NSURLRequest with empty string URL
  • Loading branch information
evermeer committed Dec 22, 2015
2 parents e6800ce + fb77d0c commit 3d9b97a
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions EVURLCache/Pod/EVURLCache.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,16 @@ public class EVURLCache : NSURLCache {

// Will be called by a NSURLConnection when it's wants to know if there is something in the cache.
public override func cachedResponseForRequest(request: NSURLRequest) -> NSCachedURLResponse? {
guard let _ = request.URL else {
EVURLCache.debugLog("CACHE not allowed for nil URLs");
return nil
}

if request.URL!.absoluteString.isEmpty {
EVURLCache.debugLog("CACHE not allowed for empty URLs");
return nil;
}

// is caching allowed
if ((request.cachePolicy == NSURLRequestCachePolicy.ReloadIgnoringCacheData || request.URL!.absoluteString.hasPrefix("file:/") || request.URL!.absoluteString.hasPrefix("data:")) && EVURLCache.networkAvailable()) {
EVURLCache.debugLog("CACHE not allowed for \(request.URL)");
Expand Down

0 comments on commit 3d9b97a

Please sign in to comment.