GeezerVison is showing github.com — Add .cjs to mimetypes · Issue #140942 · python/cpython
Add .cjs to mimetypes #140942DescriptionFeature or enhancement
Proposal:
.cjs is a JavaScript extension for CommonJS modules and is used pretty commonly (ha) by JS like Vite. It's also a format that NodeJS supports.
It could be good to add it to mimetypes since it is a widely-used extension.
Has this already been discussed elsewhere?
This is a minor feature, which does not need previous discussion elsewhere
Links to previous discussion of this feature:
No response
Linked PRs
ActivityStanFromIreland commented on Nov 3, 2025 I do not think this change is correct, it is not officially registered with IANA as required, .cjs is not listed as an alias of text/javascript:
File extension(s): .js, .mjs
ZeroIntensity commented on Nov 3, 2025 I'm not sure that mimetypes is supposed to be 100% compliant with IANA. For example, we support the .jpe extension for JPEG files, despite that not being specified.
There are also several supported extensions for application/octet-stream, and IANA doesn't specify any file extension for that. That suggests IANA's file extension specification isn't meant to be exhaustive. StanFromIreland commented on Nov 3, 2025 The two cases you mentioned exist in mimetypes since 1997 (ac8a9f3), only in 2006 was the comment requiring they be registered added. StanFromIreland commented on Nov 3, 2025 We can put it in common_types, which allows for non-IANA registered types. Per the documentation:
The optional strict argument is a flag specifying whether the list of known MIME types is limited to only the official types registered with IANA.
picnixz commented on Nov 3, 2025 FTR, mimetypes is supposed to be IANA compliant, as per the comment:
# Before adding new types, make sure they are either registered with IANA,
# at https://www.iana.org/assignments/media-types/media-types.xhtml
# or extensions, i.e. using the x- prefix
The reason why .exe & co are mapped to octect-stream is likely for convenience (the IANA type for .exe is https://www.iana.org/assignments/media-types/application/vnd.microsoft.portable-executable) and using octect-stream instead to indicate binary data is probably the best practical choice. johnfraney commented on Nov 4, 2025 ContributorAuthor More actions
We can put it in common_types, which allows for non-IANA registered types. Per the documentation:
Oh! Thank you, @StanFromIreland. I missed that comment. I'll put up a PR with that extension added to common_types instead StanFromIreland commented on Nov 4, 2025
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|