Fixed iOS encoding if path parameter is already encoded

This commit is contained in:
Rubén Panadero 2019-06-11 10:36:41 +02:00
parent 3517585d45
commit 01ac6a5d7d

View File

@ -53,7 +53,15 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
}
dispatch_async(dispatch_get_main_queue(), ^{
NSURL *fileURL = [NSURL fileURLWithPath:[path stringByReplacingOccurrencesOfString:@"file://" withString:@""]];;
NSURL *fileURL = NULL;
NSString *decodedPath = [path stringByRemovingPercentEncoding];
if ([path isEqualToString:decodedPath]) {
NSLog(@"Path parameter not encoded. Building file URL encoding it...");
fileURL = [NSURL fileURLWithPath:[path stringByReplacingOccurrencesOfString:@"file://" withString:@""]];;
} else {
NSLog(@"Path parameter already encoded. Building file URL without encoding it...");
fileURL = [NSURL URLWithString:path];
}
localFile = fileURL.path;