Dont hardcode mimetype to extension mappings

This commit is contained in:
Kovid Goyal
2026-02-08 21:54:20 +05:30
parent 08217c949d
commit ff70e2e3ab

View File

@@ -900,13 +900,10 @@ cleanup_all_ns_pending_drag_source_data(_GLFWwindow* window) {
// Generate a unique filename based on the MIME type
NSString* extension = @"data";
if (mimeType) {
NSString* mt = @(mimeType);
if ([mt hasPrefix:@"text/"]) extension = @"txt";
else if ([mt isEqualToString:@"image/png"]) extension = @"png";
else if ([mt isEqualToString:@"image/jpeg"]) extension = @"jpg";
else if ([mt isEqualToString:@"application/json"]) extension = @"json";
UTType *type = [UTType typeWithMIMEType:@(mimeType)];
extension = type.preferredFilenameExtension;
}
return [NSString stringWithFormat:@"glfw-drag-%@.%@", [[NSUUID UUID] UUIDString], extension];
return [NSString stringWithFormat:@"kitty-drag-%@.%@", [[NSUUID UUID] UUIDString], extension];
}
- (void)filePromiseProvider:(NSFilePromiseProvider*)filePromiseProvider