Skip to content

Commit 0b9726d

Browse files
committed
Fix tests
1 parent a7c1cda commit 0b9726d

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

FlyingFox/Sources/Handlers/FileHTTPHandler.swift

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,14 @@ public struct FileHTTPHandler: HTTPHandler {
5050

5151
static func makeContentType(for filename: String) -> String {
5252
let pathExtension = (filename.lowercased() as NSString).pathExtension
53-
return UTType(filenameExtension: pathExtension)?.preferredMIMEType ?? "application/octet-stream"
53+
switch pathExtension {
54+
case "wasm":
55+
return "application/wasm"
56+
case "properties":
57+
return "text/plain"
58+
default:
59+
return UTType(filenameExtension: pathExtension)?.preferredMIMEType ?? "application/octet-stream"
60+
}
5461
}
5562

5663
public func handleRequest(_ request: HTTPRequest) async throws -> HTTPResponse {

FlyingFox/Tests/Handlers/HTTPHandlerTests.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,10 @@ struct HTTPHandlerTests {
135135
FileHTTPHandler.makeContentType(for: "fish.css") == "text/css"
136136
)
137137
#expect(
138-
FileHTTPHandler.makeContentType(for: "fish.js") == "application/javascript"
138+
FileHTTPHandler.makeContentType(for: "fish.js") == "text/javascript"
139139
)
140140
#expect(
141-
FileHTTPHandler.makeContentType(for: "fish.javascript") == "application/javascript"
141+
FileHTTPHandler.makeContentType(for: "fish.javascript") == "text/javascript"
142142
)
143143
#expect(
144144
FileHTTPHandler.makeContentType(for: "fish.png") == "image/png"
@@ -162,10 +162,10 @@ struct HTTPHandlerTests {
162162
FileHTTPHandler.makeContentType(for: "fish.mp4") == "video/mp4"
163163
)
164164
#expect(
165-
FileHTTPHandler.makeContentType(for: "fish.m4v") == "video/mp4"
165+
FileHTTPHandler.makeContentType(for: "fish.m4v") == "video/x-m4v"
166166
)
167167
#expect(
168-
FileHTTPHandler.makeContentType(for: "fish.ico") == "image/x-icon"
168+
FileHTTPHandler.makeContentType(for: "fish.ico") == "image/vnd.microsoft.icon"
169169
)
170170
#expect(
171171
FileHTTPHandler.makeContentType(for: "fish.wasm") == "application/wasm"

0 commit comments

Comments
 (0)