diff --git a/Lib/mimetypes.py b/Lib/mimetypes.py index 4750408173ec07..ab4746ee1d5049 100644 --- a/Lib/mimetypes.py +++ b/Lib/mimetypes.py @@ -429,8 +429,6 @@ def _default_mime_types(): # Make sure the entry with the preferred file extension for a particular mime type # appears before any others of the same mimetype. types_map = _types_map_default = { - '.js' : 'application/javascript', - '.mjs' : 'application/javascript', '.json' : 'application/json', '.webmanifest': 'application/manifest+json', '.doc' : 'application/msword', @@ -549,6 +547,8 @@ def _default_mime_types(): '.csv' : 'text/csv', '.html' : 'text/html', '.htm' : 'text/html', + '.js' : 'text/javascript', + '.mjs' : 'text/javascript', '.n3' : 'text/n3', '.txt' : 'text/plain', '.bat' : 'text/plain', diff --git a/Lib/test/test_mimetypes.py b/Lib/test/test_mimetypes.py index 4098a22644092f..ebda5678cf9a0a 100644 --- a/Lib/test/test_mimetypes.py +++ b/Lib/test/test_mimetypes.py @@ -136,6 +136,9 @@ def test_guess_all_types(self): all.append('.no-such-ext') all = self.db.guess_all_extensions('test-type') self.assertNotIn('.no-such-ext', all) + all = self.db.guess_all_extensions('text/javascript', strict=True) + self.assertTrue(set(all) >= {'.js', '.mjs'}) + self.assertEqual(len(set(all)), len(all)) def test_encoding(self): getpreferredencoding = locale.getpreferredencoding diff --git a/Misc/NEWS.d/next/Library/2022-01-21-15-58-09.bpo-34875.Y5vWXU.rst b/Misc/NEWS.d/next/Library/2022-01-21-15-58-09.bpo-34875.Y5vWXU.rst new file mode 100644 index 00000000000000..b7cb26210acf25 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2022-01-21-15-58-09.bpo-34875.Y5vWXU.rst @@ -0,0 +1 @@ +Change '.js' and '.mjs' mime to 'text/javascript'