Recognise dragged iOS screenshots as images instead of raw data

When dragging the floating screenshot preview into a room, iOS hands us
a provider whose `suggestedName` is e.g. `Screenshot 2026-05-22 at
14.49.40`. `NSString.pathExtension` returns `"40"`, so the previous
`!pathExtension.isEmpty` check treated the timestamp's trailing segment
as a real extension. The file got written without `.jpg`/`.png`, and the
`MediaUploadingPreprocessor` then fell back to `application/octet-stream`
which is why screenshots showed up as a "data" tile.
This commit is contained in:
Quentin Gliech
2026-05-22 15:12:58 +02:00
committed by Stefan Ceriu
parent ff4fe6c728
commit 2082e71888
3 changed files with 84 additions and 2 deletions
@@ -196,8 +196,15 @@ extension NSItemProvider {
}
}
private extension NSString {
extension NSString {
/// `NSString.pathExtension` returns the trailing dot-segment regardless of whether
/// it's a real extension, and `UTType(filenameExtension:)` synthesises a `dyn.*`
/// placeholder for unknown ones instead of returning nil — so check both.
var hasPathExtension: Bool {
!pathExtension.isEmpty
guard !pathExtension.isEmpty,
let type = UTType(filenameExtension: pathExtension) else {
return false
}
return !type.isDynamic
}
}