Skip to content

Commit

Permalink
file: had to be removed
Browse files Browse the repository at this point in the history
  • Loading branch information
evermeer committed Dec 4, 2015
1 parent 92d11ae commit af19acc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion EVURLCache.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Pod::Spec.new do |s|
#

s.name = "EVURLCache"
s.version = "2.1.0"
s.version = "2.1.1"
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"
Expand Down
9 changes: 6 additions & 3 deletions EVURLCache/Pod/EVURLCache.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ 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? {
// is caching allowed
if ((request.cachePolicy == NSURLRequestCachePolicy.ReloadIgnoringCacheData || request.URL!.absoluteString.hasPrefix("file://") || request.URL!.absoluteString.hasPrefix("data:")) && EVURLCache.networkAvailable()) {
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)");
return nil;
}
Expand Down Expand Up @@ -127,8 +127,11 @@ public class EVURLCache : NSURLCache {

// create storrage folder
let storagePath: String = EVURLCache.storagePathForRequest(request, rootPath: EVURLCache._cacheDirectory)
if let storageDirectory: String = NSURL(fileURLWithPath: "\(storagePath)").URLByDeletingLastPathComponent?.absoluteString {
if var storageDirectory: String = NSURL(fileURLWithPath: "\(storagePath)").URLByDeletingLastPathComponent?.absoluteString {
do {
if storageDirectory.hasPrefix("file:") {
storageDirectory = storageDirectory.substringFromIndex(storageDirectory.startIndex.advancedBy(5))
}
try NSFileManager.defaultManager().createDirectoryAtPath(storageDirectory, withIntermediateDirectories: true, attributes: nil)
} catch let error as NSError {
EVURLCache.debugLog("Error creating cache directory \(storageDirectory)");
Expand Down Expand Up @@ -193,7 +196,7 @@ public class EVURLCache : NSURLCache {
}

// Cleanup
if localUrl.hasPrefix("file:/") {
if localUrl.hasPrefix("file:") {
localUrl = localUrl.substringFromIndex(localUrl.startIndex.advancedBy(5))
}
localUrl = localUrl.stringByReplacingOccurrencesOfString("//", withString: "/")
Expand Down

0 comments on commit af19acc

Please sign in to comment.