diff --git a/Sources/NextcloudKit/TypeIdentifiers/NKFilePropertyResolver.swift b/Sources/NextcloudKit/TypeIdentifiers/NKFilePropertyResolver.swift index 39ea3b32..acb5dd93 100644 --- a/Sources/NextcloudKit/TypeIdentifiers/NKFilePropertyResolver.swift +++ b/Sources/NextcloudKit/TypeIdentifiers/NKFilePropertyResolver.swift @@ -53,16 +53,60 @@ public final class NKFilePropertyResolver { ) -> NKFileProperty { let fileProperty = NKFileProperty() + let normalizedFileExtension = fileExtension.lowercased() + fileProperty.ext = fileExtension // MARK: - Custom MIME types switch mimeType { + case "text/markdown", "text/x-markdown": + fileProperty.classFile = .document + fileProperty.iconName = .txt + fileProperty.name = "text" + fileProperty.ext = fileExtension.isEmpty ? "md" : fileExtension + return fileProperty + case "application/vnd.excalidraw+json": fileProperty.classFile = .document fileProperty.iconName = .draw fileProperty.name = "whiteboard" - fileProperty.ext = "whiteboard" + return fileProperty + + default: + break + } + + // MARK: - Custom file extensions + + switch normalizedFileExtension { + + case "md", "markdown": + fileProperty.classFile = .document + fileProperty.iconName = .txt + fileProperty.name = "text" + fileProperty.ext = fileExtension.isEmpty ? "md" : fileExtension + return fileProperty + + case "txt", "text", "log", "csv", "tsv": + fileProperty.classFile = .document + fileProperty.iconName = .txt + fileProperty.name = "text" + return fileProperty + + case "swift", "m", "mm", "h", "c", "cpp", "hpp", + "java", "kt", "js", "ts", "html", "css", + "xml", "json", "yaml", "yml", "php", "py", + "rb", "go", "rs", "sh", "sql": + fileProperty.classFile = .document + fileProperty.iconName = .txt + fileProperty.name = "text" + return fileProperty + + case "whiteboard": + fileProperty.classFile = .document + fileProperty.iconName = .draw + fileProperty.name = "whiteboard" return fileProperty default: