Skip to content

Commit

Permalink
Improve PDF / AI (Adobe Illustrator) recognition
Browse files Browse the repository at this point in the history
  • Loading branch information
velocityzen committed Feb 18, 2022
1 parent 6839f1c commit 0211a7e
Show file tree
Hide file tree
Showing 8 changed files with 12,778 additions and 342 deletions.
2 changes: 1 addition & 1 deletion Sources/FileType/FileTypeMatch.swift
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,7 @@ struct FileTypeMatch {
FileTypeMatch(
type: .ai,
matchString: ["%PDF"],
match: { findString($0, "Adobe Illustrator", ignore: 1350) }
match: { findString($0, "AIPrivateData", ignore: 1350) }
),

FileTypeMatch(
Expand Down
9 changes: 9 additions & 0 deletions Tests/FileTypeTests/FileTypeTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,14 @@ final class FileTypeTests: XCTestCase {
testFileType("fixture-2.doc.cfb", type: .cfb)
}

func testPDF() {
testFileType("fixture-without-pdf-compatibility.ai", type: .ai)
testFileType("fixture-adobe-illustrator.pdf", type: .pdf)
testFileType("fixture-smallest.pdf", type: .pdf)
testFileType("fixture-fast-web.pdf", type: .pdf)
testFileType("fixture-printed.pdf", type: .pdf)
}

func testBytesCountForType() {
XCTAssertEqual(FileType.getBytesCountFor(type: .ac3), 2)
XCTAssertEqual(FileType.getBytesCountFor(type: .zip), 4)
Expand Down Expand Up @@ -210,6 +218,7 @@ final class FileTypeTests: XCTestCase {
("testASF", testASF),
("testJXL", testJXL),
("testCFB", testCFB),
("testPDF", testPDF),

("testBytesCountForType", testBytesCountForType),
("testBytesCountForTypes", testBytesCountForTypes),
Expand Down
Binary file added Tests/Fixtures/fixture-adobe-illustrator.pdf
Binary file not shown.
Binary file added Tests/Fixtures/fixture-fast-web.pdf
Binary file not shown.
Binary file added Tests/Fixtures/fixture-printed.pdf
Binary file not shown.
Binary file added Tests/Fixtures/fixture-smallest.pdf
Binary file not shown.
6,572 changes: 6,572 additions & 0 deletions Tests/Fixtures/fixture-without-pdf-compatibility.ai

Large diffs are not rendered by default.

6,537 changes: 6,196 additions & 341 deletions Tests/Fixtures/fixture.ai

Large diffs are not rendered by default.

0 comments on commit 0211a7e

Please sign in to comment.