Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct JavaScript MIME types + extensions per RFC 9239 #262

Merged
merged 1 commit into from
May 20, 2022

Conversation

mathiasbynens
Copy link
Contributor

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].

(mime-db already included the .mjs extension prior to this patch, so no
change needed here.)

IANA template: https://www.iana.org/assignments/media-types/text/javascript

@mathiasbynens
Copy link
Contributor Author

mathiasbynens commented May 7, 2022

Related PRs:

Copy link
Contributor

@dougwilson dougwilson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello, and thank you for your pull request. Unfortunately this cannot be accepted as-is, as the db.json file is a generated file and changes made to it directly will just be overwritten when npm run build is run. Please see https://github.com/jshttp/mime-db#contributing for how to make contributions to the database.

@dougwilson dougwilson added the pr label May 7, 2022
mathiasbynens added a commit to mathiasbynens/mime-db that referenced this pull request May 8, 2022
Certain URLs of the form `https://tools.ietf.org/rfc/${RFC_ID}.txt` redirect multiple times before arriving to the canonical resource. Example:

    $ curl -sI 'https://tools.ietf.org/rfc/rfc9239.txt' | grep Location
    Location: https://rfc-editor.org/rfc/rfc9239.txt

 $ curl -sI 'https://rfc-editor.org/rfc/rfc9239.txt' | grep Location
    Location: https://www.rfc-editor.org/rfc/rfc9239.txt

    $ curl -sI 'https://www.rfc-editor.org/rfc/rfc9239.txt' | grep HTTP
    HTTP/1.1 200 OK

`cogent`’s implicit default is to only follow 1 redirect. This patch explicitly configures `cogent` to follow up to two redirects.

This is required to properly fetch RFC 9239 and update the JavaScript MIME type entries.

Issue: jshttp#194, jshttp#262
mathiasbynens added a commit to mathiasbynens/mime-db that referenced this pull request May 8, 2022
Certain URLs of the form `https://tools.ietf.org/rfc/${RFC_ID}.txt` redirect multiple times before arriving to the canonical resource. Example:

    $ curl -sI 'https://tools.ietf.org/rfc/rfc9239.txt' | grep Location
    Location: https://rfc-editor.org/rfc/rfc9239.txt

    $ curl -sI 'https://rfc-editor.org/rfc/rfc9239.txt' | grep Location
    Location: https://www.rfc-editor.org/rfc/rfc9239.txt

    $ curl -sI 'https://www.rfc-editor.org/rfc/rfc9239.txt' | grep HTTP
    HTTP/1.1 200 OK

`cogent`’s implicit default is to only follow 1 redirect. This patch explicitly configures `cogent` to follow up to two redirects.

This is required to properly fetch RFC 9239 and update the JavaScript MIME type entries.

Issue: jshttp#194, jshttp#262
mathiasbynens added a commit to mathiasbynens/mime-db that referenced this pull request May 8, 2022
This allows us to have a clean diff to see the impact of the patch in jshttp#263.

Issue: jshttp#194, jshttp#262
@mathiasbynens
Copy link
Contributor Author

@dougwilson Thanks. It looks like it’s been a while since the scripts have been run, since there are a bunch of changes unrelated to this new RFC. I also noticed that some tweaks to the scripts are required in order to even pick up the new RFC.

Here’s what I think we should do, in order:

@dougwilson
Copy link
Contributor

So the npm run build script just takes the contents from src/ and puts them in to db.json. This is the only script I was mentioning above, and no matter how long between runs, it will still always produce the same db.json for the same src/ contents. That said, I think you are talking about the npm run update script instead of the one I mentioned. You're right -- it seems like the automated job I had for it stopped committed because the GH token I had for it was deleted by me by accident. I just created a new one and it's back up and running 🎉 .

@mathiasbynens mathiasbynens force-pushed the fix-js-mime-and-extensions branch 2 times, most recently from 789c840 to b010e3e Compare May 12, 2022 08:58
@mathiasbynens
Copy link
Contributor Author

Thanks @dougwilson! It looks like c8e4e30 picks up the upstream text/javascript changes 🎉 What’s still missing is the extensions property set to [".js", ".mjs"] (even though both extensions are explicitly listed in the IANA registrations). I’ve updated this PR to fix that by adding it to custom-types.json.

@dougwilson dougwilson merged commit 143c935 into jshttp:master May 20, 2022
@mathiasbynens mathiasbynens deleted the fix-js-mime-and-extensions branch May 20, 2022 21:34
@wesleytodd wesleytodd mentioned this pull request Jul 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants