Skip to content

Commit

Permalink
Merge pull request #447 from box/extension
Browse files Browse the repository at this point in the history
Fix how the extension gets calculated when accounting for empty filenames
  • Loading branch information
Tom Carpel authored Sep 15, 2017
2 parents ddc9be5 + 340a31b commit ef56708
Showing 1 changed file with 2 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,15 +110,10 @@ - (NSString *)box_stringByDeletingMultiplePathExtensionsIfNecessary

- (NSString *)box_fileNameExtensionAccountingForEmptyName
{
// Get the path extension from the file name.
NSString *string = [[self lastPathComponent] pathExtension];

// pathExtension returns an empty string if there are no characters before the pathExtension (e.g ".jpg" or ".m4a")
// Just simulating a correct name to correctly find the extension, since they are still valid files that can be previewed.
if (string.length == 0) {
NSString *tmp = [NSString stringWithFormat:@"tmp%@", self.lastPathComponent];
string = [tmp box_pathExtensionAccountingForZippedPackages];
}
NSString *tmp = [NSString stringWithFormat:@"tmp%@", self.lastPathComponent];
NSString *string = [tmp box_pathExtensionAccountingForZippedPackages];

return string;
}
Expand Down

0 comments on commit ef56708

Please sign in to comment.