Skip to content

Commit

Permalink
fix(magic.go): use offset according to each filetype (#3)
Browse files Browse the repository at this point in the history
Co-authored-by: Liam Galvin <liam@liam-galvin.co.uk>
  • Loading branch information
monrax and liamg authored Jul 28, 2023
1 parent e2b75d5 commit 3fda65c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion magic.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func worker(ctx context.Context, work chan job) {
select {
case <-ctx.Done():
return
case job.resultChan <- job.reference.check(job.input, 0):
case job.resultChan <- job.reference.check(job.input, job.reference.Offset):
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions magic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,11 @@ func TestNestedLookupSync(t *testing.T) {
require.Nil(t, err)

assert.Equal(t, fileType.Extension, "wav")
}

func TestLookupWithOffset(t *testing.T) {
fileType, err := Lookup([]byte{0x00, 0x00, 0x00, 0x20, 0x66, 0x74, 0x79, 0x70, 0x33, 0x67, 0x97})
require.Nil(t, err)

assert.Equal(t, fileType.Extension, "3gp")
}

0 comments on commit 3fda65c

Please sign in to comment.