diff --git a/CHANGELOG.md b/CHANGELOG.md index e5dbd53..f2a25ef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## 1.0.1 + +### Fixes + +- Remove duplicate path separators that could cause files to not be found. + ## 1.0.0 ### Features diff --git a/IONFileViewerLib.podspec b/IONFileViewerLib.podspec index 250c1d9..950ba4a 100644 --- a/IONFileViewerLib.podspec +++ b/IONFileViewerLib.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |spec| spec.name = 'IONFileViewerLib' - spec.version = '1.0.0' + spec.version = '1.0.1' spec.summary = 'Library for viewing files in iOS.' spec.description = <<-DESC diff --git a/IONFileViewerLib/IONFLVWManager.swift b/IONFileViewerLib/IONFLVWManager.swift index e815ef8..00f0ff7 100644 --- a/IONFileViewerLib/IONFLVWManager.swift +++ b/IONFileViewerLib/IONFLVWManager.swift @@ -16,9 +16,10 @@ extension IONFLVWManager: IONFLVWOpenDocumentManager { guard !filePath.isEmpty else { throw IONFLVWError.emptyFilePath } - guard let file = URL(string: filePath) else { throw IONFLVWError.couldNotOpenDocument } + let filePathToUse = replaceDuplicateSlashes(fromLocalPath: filePath) + guard let file = URL(string: filePathToUse) else { throw IONFLVWError.couldNotOpenDocument } guard !file.pathExtension.isEmpty else { throw IONFLVWError.missingFileExtension } - guard fileManager.fileExists(atPath: file.path) else { throw IONFLVWError.fileDoesNotExist(atPath: filePath) } + guard fileManager.fileExists(atPath: file.path) else { throw IONFLVWError.fileDoesNotExist(atPath: filePathToUse) } openDocumentFromLocalPath(file, completion) } @@ -59,8 +60,9 @@ extension IONFLVWManager: IONFLVWOpenDocumentManager { extension IONFLVWManager: IONFLVWPreviewMediaManager { public func previewMediaContentFromLocalPath(filePath: String) throws { guard !filePath.isEmpty else { throw IONFLVWError.emptyFilePath } - guard let file = URL(string: filePath) else { throw IONFLVWError.couldNotOpenDocument } - guard fileManager.fileExists(atPath: file.path) else { throw IONFLVWError.fileDoesNotExist(atPath: filePath) } + let filePathToUse = replaceDuplicateSlashes(fromLocalPath: filePath) + guard let file = URL(string: filePathToUse) else { throw IONFLVWError.couldNotOpenDocument } + guard fileManager.fileExists(atPath: file.path) else { throw IONFLVWError.fileDoesNotExist(atPath: filePathToUse) } previewMediaContent(file) } @@ -104,4 +106,18 @@ private extension IONFLVWManager { let resourceURL = URL(fileURLWithPath: resourcePath) return resourceURL } + + func replaceDuplicateSlashes(fromLocalPath path: String) -> String { + // remove duplicate slashes '//', except for the ones indicating the scheme (e.g. 'file://') + var pathWithoutDuplicateSeparators = path.replacingOccurrences( + of: #"(? 1.0.0' # Use the latest 1.0.x version +pod 'IONFileViewerLib', '~> 1.0.1' # Use the latest 1.0.x version ``` ## Quick Start