Skip to content

Commit

Permalink
URL's passed to closures should be file URL's
Browse files Browse the repository at this point in the history
If the URL's for unzipped files don't start with "file://" they can cause problems if
they are passed into other parts of iOS (eg share sheets).

Changing the URL constructor to generate file type URL's also correctly handles
paths with spaces. This eliminates the manual handling of these that's currently done.
  • Loading branch information
696GrocuttT committed Jul 14, 2019
1 parent 000fb6b commit 695b1fd
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions Zip/Zip.swift
Original file line number Diff line number Diff line change
Expand Up @@ -243,10 +243,8 @@ public class Zip {
progressHandler((currentPosition/totalSize))
}

if let fileHandler = fileOutputHandler,
let encodedString = fullPath.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed),
let fileUrl = URL(string: encodedString) {
fileHandler(fileUrl)
if let fileHandler = fileOutputHandler {
fileHandler(URL(fileURLWithPath: fullPath))
}

progressTracker.completedUnitCount = Int64(currentPosition)
Expand Down

0 comments on commit 695b1fd

Please sign in to comment.