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

fix(previewer): improve binary mime type check #3083

Merged

Conversation

jamestrew
Copy link
Contributor

Problem: mime type for a ts/js file can either return text/plain or application/javascript based on the contents of the file. Previously, this meant application/javascript would be considered "possibly binary". This, in conjunction with how vim.filetype.match does not give a result for a filename that ends in .ts, would lead to a typescript file taking the path of check_mime_type and eventually mime_hook.

Solution: Include application/javascript as a non-binary file type during mime type check.

closes #3068

Problem: mime type for a ts/js file can either return `text/plain` or
`application/javascript` based on the contents of the file.
Previously, this meant `application/javascript` would be considered
"possibly binary". This, in conjunction with how `vim.filetype.match`
does not give a result for a filename that ends in `.ts`, would lead to
a typescript file taking the path of `check_mime_type` and eventually
`mime_hook`.

Solution: Include `application/javascript` as a non-binary file type
during mime type check.
@jamestrew jamestrew force-pushed the fix/preview-mime-type-checks branch from 5171e27 to d6089e5 Compare May 3, 2024 01:33
@jamestrew jamestrew merged commit fac83a5 into nvim-telescope:master May 3, 2024
@jamestrew jamestrew deleted the fix/preview-mime-type-checks branch May 3, 2024 01:34
@jamestrew jamestrew added the backport-0.1.x PR to be backported to 0.1.x (Neovim 0.7 compat) label May 3, 2024
Conni2461 pushed a commit that referenced this pull request May 20, 2024
* fix(previewer): improve binary mime type check

Problem: mime type for a ts/js file can either return `text/plain` or
`application/javascript` based on the contents of the file.
Previously, this meant `application/javascript` would be considered
"possibly binary". This, in conjunction with how `vim.filetype.match`
does not give a result for a filename that ends in `.ts`, would lead to
a typescript file taking the path of `check_mime_type` and eventually
`mime_hook`.

Solution: Include `application/javascript` as a non-binary file type
during mime type check.

* [docgen] Update doc/telescope.txt
skip-checks: true

---------

Co-authored-by: Github Actions <actions@github>
(cherry picked from commit fac83a5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-0.1.x PR to be backported to 0.1.x (Neovim 0.7 compat)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] typescript (ts) files are not previewed with custom mime_hook for images
1 participant