From 3f5ec8ebfa493938047c076a566af6fdebe1b3d6 Mon Sep 17 00:00:00 2001 From: Edwin Vermeer Date: Tue, 22 Dec 2015 08:04:07 +0100 Subject: [PATCH] check empty url --- EVURLCache.podspec | 2 +- EVURLCache/Pod/EVURLCache.swift | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/EVURLCache.podspec b/EVURLCache.podspec index 10cc0bf..e79b1ad 100644 --- a/EVURLCache.podspec +++ b/EVURLCache.podspec @@ -8,7 +8,7 @@ Pod::Spec.new do |s| # s.name = "EVURLCache" -s.version = "2.1.4" +s.version = "2.1.5" s.summary = "NSURLCache subclass for handeling all web requests that use NSURLRequest" s.description = "This is a NSURLCache subclass for handeling all web requests that use NSURLRequest. (This includes UIWebView)" s.homepage = "https://github.com/evermeer/EVURLCache" diff --git a/EVURLCache/Pod/EVURLCache.swift b/EVURLCache/Pod/EVURLCache.swift index db86a6e..be73c14 100644 --- a/EVURLCache/Pod/EVURLCache.swift +++ b/EVURLCache/Pod/EVURLCache.swift @@ -53,19 +53,19 @@ 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 { + guard let url = request.URL else { EVURLCache.debugLog("CACHE not allowed for nil URLs"); return nil } - if request.URL!.absoluteString.isEmpty { + if 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)"); + if ((request.cachePolicy == NSURLRequestCachePolicy.ReloadIgnoringCacheData || url.absoluteString.hasPrefix("file:/") || url.absoluteString.hasPrefix("data:")) && EVURLCache.networkAvailable()) { + EVURLCache.debugLog("CACHE not allowed for \(url)"); return nil; }