[PATCH] Correct JavaScript MIME types + extensions per RFC 9239
Maxim Dounin
mdounin at mdounin.ru
Mon May 9 18:26:21 UTC 2022
Hello!
On Mon, May 09, 2022 at 11:46:54AM +0200, Mathias Bynens via nginx-devel wrote:
> # HG changeset patch
> # User Mathias Bynens <mathias at qiwi.be>
> # Date 1652088302 -7200
> # Mon May 09 11:25:02 2022 +0200
> # Branch fix-js-mime-and-extensions
> # Node ID 7944657540c64d92a5bdc3932710c977d984b54d
> # Parent 35afae4b3dffff6718c0cab3ceb16b9de207c20a
> Correct JavaScript MIME types + extensions per RFC 9239
>
> This patch updates the MIME type configuration per RFC 9239.
> https://www.rfc-editor.org/rfc/rfc9239
>
> First, the recommended MIME type is now `text/javascript`:
>
> > The most widely supported media type in use is `text/javascript`; all
> > others are considered historical and obsolete aliases of
> `text/javascript`.
>
> Second, the `.mjs` extension is now explicitly registered:
>
> > The `.mjs` file extension signals that the file represents a JavaScript
> > module. Execution environments that rely on file extensions to
> > determine how to process inputs parse `.mjs` files using the Module
> > grammar of [ECMA-262].
>
> IANA template: https://www.iana.org/assignments/media-types/text/javascript
>
> diff -r 35afae4b3dff -r 7944657540c6 conf/mime.types
> --- a/conf/mime.types Fri Apr 29 17:38:01 2022 +0400
> +++ b/conf/mime.types Mon May 09 11:25:02 2022 +0200
> @@ -5,7 +5,7 @@
> text/xml xml;
> image/gif gif;
> image/jpeg jpeg jpg;
> - application/javascript js;
> + text/javascript js mjs;
> application/atom+xml atom;
> application/rss+xml rss;
>
> diff -r 35afae4b3dff -r 7944657540c6
> src/http/modules/ngx_http_charset_filter_module.c
> --- a/src/http/modules/ngx_http_charset_filter_module.c Fri Apr 29 17:38:01
> 2022 +0400
> +++ b/src/http/modules/ngx_http_charset_filter_module.c Mon May 09 11:25:02
> 2022 +0200
> @@ -128,7 +128,7 @@
> ngx_string("text/xml"),
> ngx_string("text/plain"),
> ngx_string("text/vnd.wap.wml"),
> - ngx_string("application/javascript"),
> + ngx_string("text/javascript"),
> ngx_string("application/rss+xml"),
> ngx_null_string
> };
Thanks for the patch.
I've added a link to the patch to the most relevant ticket
(https://trac.nginx.org/nginx/ticket/2216).
--
Maxim Dounin
http://mdounin.ru/
More information about the nginx-devel
mailing list