aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNavan Chauhan <navanchauhan@gmail.com>2024-03-08 16:43:03 -0700
committerNavan Chauhan <navanchauhan@gmail.com>2024-03-08 16:43:03 -0700
commitae775de855a2dc60072493ac2915b16f258ca7f1 (patch)
tree99840da6afd146b3184bd12b4540dcd5186ff36b
parentbf61c4357d3a1ff005f60d8cd09a39422881dab9 (diff)
Fix filetype for search results
-rw-r--r--Sources/swift-gopher/gopherHandler.swift6
1 files changed, 5 insertions, 1 deletions
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: "")