From ae775de855a2dc60072493ac2915b16f258ca7f1 Mon Sep 17 00:00:00 2001 From: Navan Chauhan Date: Fri, 8 Mar 2024 16:43:03 -0700 Subject: Fix filetype for search results --- Sources/swift-gopher/gopherHandler.swift | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Sources/swift-gopher/gopherHandler.swift b/Sources/swift-gopher/gopherHandler.swift index 0ac5c31..bfca8de 100644 --- a/Sources/swift-gopher/gopherHandler.swift +++ b/Sources/swift-gopher/gopherHandler.swift @@ -277,9 +277,13 @@ final class GopherHandler: ChannelInboundHandler { var gopherResponse: [String] = [] for (_, file_path) in search_results { - let item_type = + var item_type = try? URL(fileURLWithPath: file_path).resourceValues(forKeys: [.isDirectoryKey]).isDirectory ?? false ? "1" : "0" + if item_type == "0" { + item_type = fileTypeToGopherItem( + fileType: getFileType(fileExtension: URL(fileURLWithPath: file_path).pathExtension)) + } let item_host = gopherdata_host let item_port = gopherdata_port let item_path = file_path.replacingOccurrences(of: base_dir.path, with: "") -- cgit v1.2.3