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

TXT files with digits are detected as json #175

Closed
IevgenLuzan opened this issue Aug 16, 2021 · 4 comments · Fixed by #176
Closed

TXT files with digits are detected as json #175

IevgenLuzan opened this issue Aug 16, 2021 · 4 comments · Fixed by #176
Assignees

Comments

@IevgenLuzan
Copy link

Attach the file for which the detection is inaccurate
11.txt

Expected MIME type
txt

Returned MIME type
json

Version of the library you are using
the semver version or the hash of the commit
1.3.0
Output of go version
...
1.16.6
Additional context
Add any other context about the problem here.

Reproduсed with any txt file that contents just digits.

@gabriel-vasile
Copy link
Owner

It reproduces with a single string too.
I guess the fix is to return json just for files containing a json object or a json array.
Just 1234 or "abcd" should return txt.
This would be inline with that file --mime 11.txt does too.

@gabriel-vasile gabriel-vasile self-assigned this Aug 16, 2021
@IevgenLuzan
Copy link
Author

Is there any chanse override that behavior for now?
mimetype.Extend does not help here.
@gabriel-vasile

@gabriel-vasile
Copy link
Owner

I made the PR with the fix. If you don't want to wait until the new version is released, you can run:

go get github.com/gabriel-vasile/mimetype@dd10de59634d

Thank you for reporting this issue.

@IevgenLuzan
Copy link
Author

Thank you for the quik help.
It works.

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 a pull request may close this issue.

2 participants