Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sort matchers by extension makes matching deterministic #73

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sergolius
Copy link

No description provided.

@henvic
Copy link

henvic commented Sep 27, 2019

While deterministic is better than undeterministic, shouldn't it try to match to the "most specialized" first? Like, probably change the mimetypes map to a slice of mimetypes and try to sort it manually in the best possible order.

@slockij
Copy link

slockij commented Sep 27, 2019

another suggestion - it could also return multiple values (so all matching):
`filetype.MatchMulti([]byte) ([]filetype.Type, error)

@h2non
Copy link
Owner

h2non commented Mar 5, 2020

This is a good initial approach, but not enough. We need to explicitly order matchers based on the most specific first. I guess it's better to define an array that respects order on each matchers category file.

A PR is very welcome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants