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 https://bugs.python.org/issue46035 mimetypes.guess_type https://docs.python.org/3/library/mimetypes.html#mimetypes.guess_type unregistered media type https://datatracker.ietf.org/doc/html/rfc4329#section-3 _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/V53XGQPIY7ZAISMTQHPHKGWZNSN5EXQG/ Code of Conduct: http://python.org/psf/codeofconduct/