Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Loading