Skip to content

Commit

Permalink
Merge pull request #95 from Infomaniak/fixUIImageDetect
Browse files Browse the repository at this point in the history
fix: UIImage was wrongfully detected with files containing an image
  • Loading branch information
Ambrdctr authored Jan 15, 2024
2 parents 7dd09b2 + 85721ea commit 504932a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@ import InfomaniakDI

/// Extending NSItemProvider for detecting file type, business logic.
public extension NSItemProvider {
/// image identifiers supported by the app
/// image file identifiers supported by the app
private static let imageUTIIdentifiers = [
UTI.image.identifier,
UTI.jpeg.identifier,
UTI.tiff.identifier,
UTI.gif.identifier,
Expand Down Expand Up @@ -87,13 +86,13 @@ public extension NSItemProvider {
return .isText
} else if hasItemConformingToAnyOfTypeIdentifiers(Self.imageUTIIdentifiers) {
return .isImageData
} else if registeredTypeIdentifiers.count == 1 &&
registeredTypeIdentifiers.first == UTI.image.identifier {
return .isUIImage
} else if hasItemConformingToAnyOfTypeIdentifiers(Self.directoryUTIIdentifiers) {
return .isDirectory
} else if hasItemConformingToAnyOfTypeIdentifiers(Self.compressedUTIIdentifiers) {
return .isCompressedData(identifier: typeIdentifier)
} else if registeredTypeIdentifiers.count == 1 &&
registeredTypeIdentifiers.first == UTI.image.identifier {
return .isUIImage
} else {
return .isMiscellaneous(identifier: typeIdentifier)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@ public struct UTI: RawRepresentable {

public static let webArchive = UTI(rawValue: kUTTypeWebArchive)

/// Typical for UIImage
public static let image = UTI(rawValue: kUTTypeImage)

public static let jpeg = UTI(rawValue: kUTTypeJPEG)
Expand Down

0 comments on commit 504932a

Please sign in to comment.