Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion Sources/FileType/Supported.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1679,7 +1679,7 @@ public extension MimeType {
return bytes[0...2] == [0x49, 0x49, 0xBC]
}),
.init(mime: "image/webp", type: .webp, bytesCount: 4, matches: { bytes, _ in
return bytes[8...11] == [0x57, 0x45, 0x42, 0x50]
return bytes.count > 7 && bytes[8...11] == [0x57, 0x45, 0x42, 0x50]
}),
.init(mime: "image/x-adobe-dng", type: .dng, bytesCount: 4, matches: { bytes, _ in
// TODO: Implement magic number check for image/x-adobe-dng
Expand Down
5 changes: 5 additions & 0 deletions Tests/FileTypeTests/FileTypeTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -129,3 +129,8 @@ import Foundation
}
}

@Test func testBlankTxt() async throws {
let data = Data([0x33, 0x2E, 0x31, 0x30, 0x2E, 0x33, 0x0A]) // emty txt file bytes
#expect(FileType.mimeType(data: data) == nil)
}