From 9d228353438a39381009af1d7bee456ced012da6 Mon Sep 17 00:00:00 2001 From: Hampton Maxwell Date: Wed, 8 Aug 2018 13:56:11 -0700 Subject: [PATCH] Rework logic for extension detection --- ios/VideoCaching/RCTVideoCache.m | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/ios/VideoCaching/RCTVideoCache.m b/ios/VideoCaching/RCTVideoCache.m index 4f23a113..d4d922c2 100644 --- a/ios/VideoCaching/RCTVideoCache.m +++ b/ios/VideoCaching/RCTVideoCache.m @@ -105,7 +105,7 @@ NSString * pathExtension = [uriWithoutQueryParams pathExtension]; NSArray * supportedExtensions = @[@"m4v", @"mp4", @"mov"]; - if ([supportedExtensions containsObject:pathExtension] == NO) { + if ([pathExtension isEqualToString:@""]) { NSDictionary *userInfo = @{ NSLocalizedDescriptionKey: NSLocalizedString(@"Missing file extension.", nil), NSLocalizedFailureReasonErrorKey: NSLocalizedString(@"Missing file extension.", nil), @@ -114,11 +114,12 @@ NSError *error = [NSError errorWithDomain:@"RCTVideoCache" code:RCTVideoCacheStatusMissingFileExtension userInfo:userInfo]; @throw error; - } else if ([pathExtension isEqualToString:@"m3u8"]) { + } else if (![supportedExtensions containsObject:pathExtension]) { + // Notably, we don't currently support m3u8 (HLS playlists) NSDictionary *userInfo = @{ - NSLocalizedDescriptionKey: NSLocalizedString(@"Missing file extension.", nil), - NSLocalizedFailureReasonErrorKey: NSLocalizedString(@"Missing file extension.", nil), - NSLocalizedRecoverySuggestionErrorKey: NSLocalizedString(@"Missing file extension.", nil) + NSLocalizedDescriptionKey: NSLocalizedString(@"Unsupported file extension.", nil), + NSLocalizedFailureReasonErrorKey: NSLocalizedString(@"Unsupported file extension.", nil), + NSLocalizedRecoverySuggestionErrorKey: NSLocalizedString(@"Unsupported file extension.", nil) }; NSError *error = [NSError errorWithDomain:@"RCTVideoCache" code:RCTVideoCacheStatusUnsupportedFileExtension userInfo:userInfo];