"x-" prefix indicates ad hoc (unofficial), not deprecated.
mimetypes are parsed from the file /etc/mime.types
cat /etc/mime.types | grep javascript
application/javascript js
application/x-javascript js
actual:
mimetypes.guess_type("x.js") == "application/x-javascript"
-> deprecated mimetype
expected:
mimetypes.guess_type("x.js") == "application/javascript"
spoiler: here, the "x-" part is deprecated.
mimetypes.guess_type returns the deprecated mimetype
because python returns the last entry in the /etc/mime.types file
which is sorted alphabetically
proposed solution:
use a smarter conflict-resolution when parsing /etc/mime.types.
when two entries are found for one file-extension,
avoid using a deprecated mimetype.
rfc4329 lists 16 items for "unregistered media type"
these could be hard-coded as set-of-strings, or as regex.
related bug report
mimetypes.guess_type
unregistered media type
_______________________________________________