Querying file extension by the MIME type may return multiple extensions
When multiple extensions have the same MIME type, the code here can become problematic:
https://github.com/posit-dev/connectapi/blob/67a52e20e147a9f1102ac73c73370c7498913a47/R/thumbnail.R#L53-L58
For example, image/jpeg currently corresponds to four extension in the dev version of the mime package:
library(mime)
mimemap[mimemap == 'image/jpeg']
jfif jpe jpeg jpg
"image/jpeg" "image/jpeg" "image/jpeg" "image/jpeg"
That means the test here will be broken (since it assumes the first extension to be .jpeg, which has become .jfif in the dev version of mime):
https://github.com/posit-dev/connectapi/blob/67a52e20e147a9f1102ac73c73370c7498913a47/tests/testthat/test-thumbnail.R#L35
I adjusted the order of extensions in mime::mimemap to make sure jpeg appears earlier than other extensions for image/jpeg. You may still need to rethink about the assumption of .jpeg being the first entry here.
Thanks @yihui. We'll keep this issue open and consider alternate approaches to this problem.
You are welcome!