-
Notifications
You must be signed in to change notification settings - Fork 24
feat: improve MIME type conflict resolution with priority-based algorithm #227
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
Conversation
Generated Code DiffThis PR changes the generated Click to expand diff--- base-consts.txt 2026-01-20 20:00:42.638290414 +0000
+++ pr-consts.txt 2026-01-20 20:00:42.641290489 +0000
@@ -1481,7 +1481,7 @@
public const string Efif = "application/vnd.picsel";
public const string Ei6 = "application/vnd.pg.osasli";
public const string Elc = "application/octet-stream";
- public const string Emf = "application/x-msmetafile";
+ public const string Emf = "image/emf";
public const string Eml = "message/rfc822";
public const string Emma = "application/emma+xml";
public const string Emotionml = "application/emotionml+xml";
@@ -1685,7 +1685,7 @@
public const string Jph = "image/jph";
public const string Jpm = "image/jpm";
public const string Jpx = "image/jpx";
- public const string Js = "application/javascript";
+ public const string Js = "text/javascript";
public const string Json = "application/json";
public const string Json5 = "application/json5";
public const string Jsonld = "application/ld+json";
@@ -1822,8 +1822,8 @@
public const string Mp2 = "audio/mpeg";
public const string Mp21 = "application/mp21";
public const string Mp2a = "audio/mpeg";
- public const string Mp3 = "audio/mp3";
- public const string Mp4 = "application/mp4";
+ public const string Mp3 = "audio/mpeg";
+ public const string Mp4 = "video/mp4";
public const string Mp4a = "audio/mp4";
public const string Mp4s = "application/mp4";
public const string Mp4v = "video/mp4";
@@ -1833,7 +1833,7 @@
public const string Mpeg = "video/mpeg";
public const string Mpf = "application/media-policy-dataset+xml";
public const string Mpg = "video/mpeg";
- public const string Mpg4 = "application/mp4";
+ public const string Mpg4 = "video/mp4";
public const string Mpga = "audio/mpeg";
public const string Mpkg = "application/vnd.apple.installer+xml";
public const string Mpm = "application/vnd.blueice.multipass";
@@ -1859,7 +1859,7 @@
public const string Msp = "application/octet-stream";
public const string Msty = "application/vnd.muvee.style";
public const string Mtl = "model/mtl";
- public const string Mts = "model/vnd.mts";
+ public const string Mts = "video/mp2t";
public const string Mus = "application/vnd.musician";
public const string Musd = "application/mmt-usd+xml";
public const string Musicxml = "application/vnd.recordare.musicxml+xml";
@@ -1899,7 +1899,7 @@
public const string Oas = "application/vnd.fujitsu.oasys";
public const string Obd = "application/x-msbinder";
public const string Obgx = "application/vnd.openblox.game+xml";
- public const string Obj = "application/x-tgif";
+ public const string Obj = "model/obj";
public const string Oda = "application/oda";
public const string Odb = "application/vnd.oasis.opendocument.database";
public const string Odc = "application/vnd.oasis.opendocument.chart";
@@ -2008,7 +2008,7 @@
public const string Pptm = "application/vnd.ms-powerpoint.presentation.macroenabled.12";
public const string Pptx = "application/vnd.openxmlformats-officedocument.presentationml.presentation";
public const string Pqa = "application/vnd.palm";
- public const string Prc = "application/x-mobipocket-ebook";
+ public const string Prc = "model/prc";
public const string Pre = "application/vnd.lotus-freelance";
public const string Prf = "application/pics-rules";
public const string Provx = "application/provenance+xml";
@@ -2075,7 +2075,7 @@
public const string Rsd = "application/rsd+xml";
public const string Rsheet = "application/urc-ressheet+xml";
public const string Rss = "application/rss+xml";
- public const string Rtf = "application/rtf";
+ public const string Rtf = "text/rtf";
public const string Rtx = "text/richtext";
public const string Run = "application/x-makeself";
public const string Rusd = "application/route-usd+xml";
@@ -2174,7 +2174,7 @@
public const string Stf = "application/vnd.wt.stf";
public const string Sti = "application/vnd.sun.xml.impress.template";
public const string Stk = "application/hyperstudio";
- public const string Stl = "application/vnd.ms-pki.stl";
+ public const string Stl = "model/stl";
public const string Stp = "model/step";
public const string Stpnc = "model/step";
public const string Stpx = "model/step+xml";
@@ -2335,7 +2335,7 @@
public const string Wadl = "application/vnd.sun.wadl+xml";
public const string War = "application/java-archive";
public const string Wasm = "application/wasm";
- public const string Wav = "audio/wav";
+ public const string Wav = "audio/x-wav";
public const string Wax = "audio/x-ms-wax";
public const string Wbmp = "image/vnd.wap.wbmp";
public const string Wbs = "application/vnd.criticaltools.wbs+xml";
@@ -2356,7 +2356,7 @@
public const string Wm = "video/x-ms-wm";
public const string Wma = "audio/x-ms-wma";
public const string Wmd = "application/x-ms-wmd";
- public const string Wmf = "application/x-msmetafile";
+ public const string Wmf = "image/wmf";
public const string Wml = "text/vnd.wap.wml";
public const string Wmlc = "application/vnd.wap.wmlc";
public const string Wmls = "text/vnd.wap.wmlscript";
@@ -2379,9 +2379,9 @@
public const string Wvx = "video/x-ms-wvx";
public const string X32 = "application/x-authorware-bin";
public const string X3d = "model/x3d+xml";
- public const string X3db = "model/x3d+binary";
+ public const string X3db = "model/x3d+fastinfoset";
public const string X3dbz = "model/x3d+binary";
- public const string X3dv = "model/x3d+vrml";
+ public const string X3dv = "model/x3d-vrml";
public const string X3dvz = "model/x3d+vrml";
public const string X3dz = "model/x3d+xml";
public const string Xaml = "application/xaml+xml";
@@ -2403,7 +2403,7 @@
public const string Xel = "application/xcap-el+xml";
public const string Xenc = "application/xenc+xml";
public const string Xer = "application/patch-ops-error+xml";
- public const string Xfdf = "application/vnd.adobe.xfdf";
+ public const string Xfdf = "application/xfdf";
public const string Xfdl = "application/vnd.xfdl";
public const string Xht = "application/xhtml+xml";
public const string Xhtm = "application/vnd.pwg-xhtml-print+xml";
@@ -2413,7 +2413,7 @@
public const string Xla = "application/vnd.ms-excel";
public const string Xlam = "application/vnd.ms-excel.addin.macroenabled.12";
public const string Xlc = "application/vnd.ms-excel";
- public const string Xlf = "application/x-xliff+xml";
+ public const string Xlf = "application/xliff+xml";
public const string Xlm = "application/vnd.ms-excel";
public const string Xls = "application/vnd.ms-excel";
public const string Xlsb = "application/vnd.ms-excel.sheet.binary.macroenabled.12";
@@ -2424,7 +2424,7 @@
public const string Xltx = "application/vnd.openxmlformats-officedocument.spreadsheetml.template";
public const string Xlw = "application/vnd.ms-excel";
public const string Xm = "audio/xm";
- public const string Xml = "application/xml";
+ public const string Xml = "text/xml";
public const string Xns = "application/xcap-ns+xml";
public const string Xo = "application/vnd.olpc-sugar";
public const string Xop = "application/xop+xml";
@@ -2462,7 +2462,7 @@
public const string Z7 = "application/x-zmachine";
public const string Z8 = "application/x-zmachine";
public const string Zaz = "application/vnd.zzazz.deck+xml";
- public const string Zip = "application/x-zip-compressed";
+ public const string Zip = "application/zip";
public const string Zir = "application/vnd.zul";
public const string Zirz = "application/vnd.zul";
public const string Zmm = "application/vnd.handheld-entertainment+xml";
|
viceice
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should publish this as major v4 as there is a significant change in mapping extension to mime type
|
now conflicted |
cb432b9 to
ae66034
Compare
|
Howdy! Is this being deployed as a new package anytime soon? Thanks! |
|
will try to release a v4 today |
|
|
Thank you! |
Previously, when multiple MIME types claimed the same file extension, the generator used a "first come, first served" approach based on alphabetical order in mime-db. This led to poor mappings like .mp4 →
application/mp4instead ofvideo/mp4.The new algorithm resolves conflicts using a two-tier priority system:
Source priority (higher wins):
Type specificity (tiebreaker when sources are equal):
Some notable improved mappings:
Note: .wav maps to audio/x-wav due to mime-db missing source annotation on audio/wav (a data quality issue in the upstream database). An issue should be created on their repo to investigate this. Luckily
.wavfiles are rarely used compared to the types that this PR fixes.There now a decent amount of duplicated code between the tests and the t4 template. We would probably have to refactor the system to use a source generator to improve this, because sharing code with a t4 template file is complex and awkward.
Fixes #160