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

Add extensions for obsolete mimetypes #112

Open
danny0838 opened this issue Dec 29, 2017 · 11 comments
Open

Add extensions for obsolete mimetypes #112

danny0838 opened this issue Dec 29, 2017 · 11 comments

Comments

@danny0838
Copy link

danny0838 commented Dec 29, 2017

Sometimes we'd want to lookup a file extension from a given mimetype. For example, we want to get "js" if we are given a mimetype "text/javascript". This is currently not possible since the "extensions" key for "text/javascript" is not defined.

I'd suggest that we define an obsolete mimetype, such as "text/javascript", like this:

"text/javascript": {
  "source": "iana",
  "compressible": true,
  "obsolete": true,
  "extensions": ["js"]
},

So that the application is able to get an extension when "text/javascript" is given. If the application wants to reversely look for the mimetype for "js", it can ignore the "text/javascript" according to its "obsolete" value.

We can optionally add a "canonical": "application/javascript" to indicate what this obsolete mimetype is now redirected to.

@dougwilson
Copy link
Contributor

We're not willing to manually maintain a list like this. The purpose of this database is to aggregate sources though the build scripts. Is there a source somewhere we can scrape this data from?

@danny0838
Copy link
Author

The IANA source have most of the information. For example, the "text/javascript" template page contains a line of "File extension(s): .js" and a line of "Intended usage: OBSOLETE".

@dougwilson
Copy link
Contributor

Ah, so it sounds like this can be just adding some additional scraping rules into the IANA scraper.

@danny0838
Copy link
Author

I did a little check and it seems that many mimetypes defined by IANA also have file extensions missing, such as application/cccex (.c3ex) and text/vnd-curl (.curl).

Another problem could arise is that how do we merge the file extensions if they are defined differently in IANA, Apache, and nginx sources?

@dougwilson
Copy link
Contributor

I assume just list them all unless there is another suggestion.

@danny0838
Copy link
Author

danny0838 commented Dec 29, 2017

I am not sure how you currently do it. I would suggest:

  1. Add the extensions listed by IANA using the order IANA suggests.
  2. Append the extensions listed by Apache and not listed by IANA using the order Apache uses.
  3. Append the extensions listed by nginx and not listed by IANA and Apache using the order nginx uses.

(Assume the priority is IANA >Apache >ngnix)

@dougwilson
Copy link
Contributor

I believe that is what the build script does already 👍

@danny0838
Copy link
Author

This issue is here for a year. Any plan on it?

@dougwilson
Copy link
Contributor

Just make a pull request updating the build script to pull the data on if types are obsolete from the IANA database, right?

@danny0838
Copy link
Author

I think so. Are you going to implement it?

@dougwilson
Copy link
Contributor

Perhaps one day if I have the time and desire to. If you want to see it earlier, feel free to implement 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants