Skip to content

Commit 3acdc25

Browse files
committed
fixes for catalog
1 parent 10a2cef commit 3acdc25

13 files changed

Lines changed: 10898 additions & 3502 deletions

File tree

.github/workflows/mime-sync.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ jobs:
7979
title: "chore: sync MIME database"
8080
body: |
8181
Automated update of the MIME database from the IANA media types registry,
82-
and Apache mime.types.
82+
Apache mime.types, mime-db gap-fill entries, and curated ManagedCode overrides.
8383
8484
When MIME data changes, this PR also bumps the package patch version.
8585
See the workflow summary for the IANA registry date, source counts, and version bump.

Directory.Build.props

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
<RepositoryUrl>https://github.com/managedcode/MimeTypes</RepositoryUrl>
1818
<PackageProjectUrl>https://github.com/managedcode/MimeTypes</PackageProjectUrl>
1919
<Product>Managed Code - MimeTypes</Product>
20-
<Version>10.0.4</Version>
21-
<PackageVersion>10.0.4</PackageVersion>
20+
<Version>10.0.5</Version>
21+
<PackageVersion>10.0.5</PackageVersion>
2222

2323
</PropertyGroup>
2424
<PropertyGroup Condition="'$(GITHUB_ACTIONS)' == 'true'">

ManagedCode.MimeTypes.Sync/ManagedCode.MimeTypes.Sync.csproj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,9 @@
77
<Nullable>enable</Nullable>
88
<ImplicitUsings>enable</ImplicitUsings>
99
</PropertyGroup>
10+
<ItemGroup>
11+
<None Update="curatedMimeTypes.json">
12+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
13+
</None>
14+
</ItemGroup>
1015
</Project>

ManagedCode.MimeTypes.Sync/Program.cs

Lines changed: 244 additions & 32 deletions
Large diffs are not rendered by default.
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
[
2+
{
3+
"extension": "tar.gz",
4+
"mime": "application/gzip",
5+
"source": "ManagedCode compatibility",
6+
"reason": "Compound archive extension; upstream MIME listings usually map only the terminal .gz extension."
7+
},
8+
{
9+
"extension": "gz",
10+
"mime": "application/gzip",
11+
"source": "MDN Common media types",
12+
"reason": "Common web mapping; keeps gzip archives on the registered application/gzip value."
13+
},
14+
{
15+
"extension": "tar.bz2",
16+
"mime": "application/x-bzip2",
17+
"source": "ManagedCode compatibility",
18+
"reason": "Compound archive extension; upstream MIME listings usually map only the terminal .bz2 extension."
19+
},
20+
{
21+
"extension": "tar.xz",
22+
"mime": "application/x-xz",
23+
"source": "ManagedCode compatibility",
24+
"reason": "Compound archive extension; upstream MIME listings usually map only the terminal .xz extension."
25+
},
26+
{
27+
"extension": "tar.zst",
28+
"mime": "application/zstd",
29+
"source": "ManagedCode compatibility",
30+
"reason": "Compound archive extension; upstream MIME listings usually map only the terminal .zst extension."
31+
},
32+
{
33+
"extension": "aac",
34+
"mime": "audio/aac",
35+
"source": "MDN Common media types",
36+
"reason": "Common browser/runtime mapping; Apache still carries the older audio/x-aac value."
37+
},
38+
{
39+
"extension": "cda",
40+
"mime": "application/x-cdf",
41+
"source": "MDN Common media types",
42+
"reason": "Common Windows CD audio extension absent from IANA and Apache extension listings."
43+
},
44+
{
45+
"extension": "d.ts",
46+
"mime": "application/typescript",
47+
"source": "ManagedCode compatibility",
48+
"reason": "TypeScript declaration files need a compound extension mapping before the terminal .ts MPEG transport-stream mapping."
49+
},
50+
{
51+
"extension": "cjs",
52+
"mime": "application/node",
53+
"source": "Node.js ecosystem",
54+
"reason": "CommonJS module extension used by Node.js projects."
55+
},
56+
{
57+
"extension": "mjs",
58+
"mime": "text/javascript",
59+
"source": "MDN Common media types",
60+
"reason": "JavaScript module extension; browsers expect text/javascript."
61+
},
62+
{
63+
"extension": "wasm",
64+
"mime": "application/wasm",
65+
"source": "WebAssembly",
66+
"reason": "Common WebAssembly module mapping."
67+
},
68+
{
69+
"extension": "heic",
70+
"mime": "image/heic",
71+
"source": "IANA media types",
72+
"reason": "Common HEIF image extension; keeps extension lookup aligned with registered image/heic metadata."
73+
},
74+
{
75+
"extension": "heif",
76+
"mime": "image/heif",
77+
"source": "IANA media types",
78+
"reason": "Common HEIF image extension; keeps extension lookup aligned with registered image/heif metadata."
79+
},
80+
{
81+
"extension": "ics",
82+
"mime": "text/calendar",
83+
"source": "MDN Common media types",
84+
"reason": "Common iCalendar file extension."
85+
},
86+
{
87+
"extension": "php",
88+
"mime": "application/x-httpd-php",
89+
"source": "MDN Common media types",
90+
"reason": "Common server-side script mapping absent from IANA and Apache extension listings."
91+
},
92+
{
93+
"extension": "ps1",
94+
"mime": "application/x-powershell",
95+
"source": "ManagedCode compatibility",
96+
"reason": "Common PowerShell script extension absent from IANA and Apache extension listings."
97+
},
98+
{
99+
"extension": "appx",
100+
"mime": "application/vnd.ms-appx",
101+
"source": "Windows app package ecosystem",
102+
"reason": "Common Windows app package extension absent from Apache extension listings."
103+
},
104+
{
105+
"extension": "event_stream",
106+
"mime": "text/event-stream",
107+
"source": "MDN Server-sent events",
108+
"reason": "Server-sent events require text/event-stream, but the MIME has no normal file extension in IANA or Apache."
109+
}
110+
]

ManagedCode.MimeTypes.Tests/GeneratorTests.cs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ public void ExtensionsTest()
1515
MimeHelper.GetMimeType("C:\\\\users\\file.txt").ShouldBe(MimeHelper.TXT);
1616
MimeHelper.GetMimeType("https://cdn.example.com/assets/image.png?version=1").ShouldBe(MimeHelper.PNG);
1717
MimeHelper.GetMimeType("ARCHIVE.TAR.GZ").ShouldBe(MimeHelper.GZ);
18+
MimeHelper.GetMimeType("module.d.ts").ShouldBe(MimeHelper.D_TS);
19+
MimeHelper.GetMimeType("events.event_stream").ShouldBe(MimeHelper.EVENT_STREAM);
1820
}
1921

2022
[Fact]
@@ -29,11 +31,13 @@ public void EmptyExtensionsTest()
2931
public void GeneratedPropertiesTest()
3032
{
3133
// Test static properties generated from mimeTypes.json
34+
const string eventStreamMime = "text/event-stream";
3235
MimeHelper.PDF.ShouldBe(MimeHelper.GetMimeType(".pdf"));
3336
MimeHelper.DOCX.ShouldBe(MimeHelper.GetMimeType(".docx"));
3437
MimeHelper.PNG.ShouldBe(MimeHelper.GetMimeType(".png"));
3538
MimeHelper.MP4.ShouldBe(MimeHelper.GetMimeType(".mp4"));
3639
MimeHelper._7Z.ShouldBe(MimeHelper.GetMimeType(".7z"));
40+
MimeHelper.EVENT_STREAM.ShouldBe(eventStreamMime);
3741
}
3842

3943
[Fact]
@@ -45,6 +49,30 @@ public void GeneratedDictionaryTest()
4549
MimeHelper.GetMimeType(".7z").ShouldBe(MimeHelper._7Z);
4650
}
4751

52+
[Theory]
53+
[InlineData("index.html", "text/html")]
54+
[InlineData("data.json", "application/json")]
55+
[InlineData("feed.xml", "application/xml")]
56+
[InlineData("clip.mp4", "video/mp4")]
57+
[InlineData("song.mid", "audio/midi")]
58+
[InlineData("audio.aac", "audio/aac")]
59+
[InlineData("track.cda", "application/x-cdf")]
60+
[InlineData("index.php", "application/x-httpd-php")]
61+
public void CommonWebExtensions_ShouldPreferConventionalMappings(string fileName, string expectedMime)
62+
{
63+
MimeHelper.GetMimeType(fileName).ShouldBe(expectedMime);
64+
}
65+
66+
[Theory]
67+
[InlineData("diagram.mermaid", "application/vnd.mermaid")]
68+
[InlineData("document.typ", "text/vnd.typst")]
69+
[InlineData("notes.rst", "text/prs.fallenstein.rst")]
70+
[InlineData("picture.hsj2", "image/hsj2")]
71+
public void NumberedIanaTemplateExtensions_ShouldBeAvailable(string fileName, string expectedMime)
72+
{
73+
MimeHelper.GetMimeType(fileName).ShouldBe(expectedMime);
74+
}
75+
4876
[Fact]
4977
public void GetExtensionsShouldReturnKnownExtensions()
5078
{

ManagedCode.MimeTypes.Tests/ManagedCode.MimeTypes.Tests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
</PropertyGroup>
1010
<PropertyGroup>
1111
<VSTestLogger>trx%3bLogFileName=$(MSBuildProjectName).trx</VSTestLogger>
12-
<VSTestResultsDirectory>$(MSBuildThisFileDirectory)</VSTestResultsDirectory>
12+
<VSTestResultsDirectory>$(MSBuildThisFileDirectory)TestResults</VSTestResultsDirectory>
1313
</PropertyGroup>
1414
<ItemGroup>
1515
<None Update="xunit.runner.json">

ManagedCode.MimeTypes.Tests/MimeMetadataTests.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,27 @@ public void TryGetMimeTypeInfoByExtension_ShouldUseSameCandidateRulesAsMimeLooku
2828
info.Extensions.ShouldContain(".pdf");
2929
}
3030

31+
[Fact]
32+
public void TryGetMimeTypeInfoByExtension_ShouldPreferEffectiveMappingOverRawTemplateExtension()
33+
{
34+
var effectiveMime = MimeHelper.GetMimeType("diagram.mmd");
35+
36+
effectiveMime.ShouldBe("application/vnd.chipnuts.karaoke-mmd");
37+
MimeHelper.TryGetMimeTypeInfoByExtension("diagram.mmd", out var info).ShouldBeTrue();
38+
info.Mime.ShouldBe(effectiveMime);
39+
}
40+
3141
[Fact]
3242
public void GetKnownMimeTypes_ShouldIncludeIanaAndSupplementalMetadata()
3343
{
3444
var known = MimeHelper.GetKnownMimeTypes();
3545

3646
known.ShouldContain(static info => info.Mime == "application/pdf" && info.IsIanaRegistered);
3747
known.ShouldContain(static info => info.Mime == "application/x-7z-compressed" && !info.IsIanaRegistered && info.Source == "apache");
48+
known.ShouldContain(static info => info.Mime == "application/x-powershell" && !info.IsIanaRegistered && info.Source == "curated");
49+
known.ShouldContain(static info => info.Mime == "text/event-stream" && !info.IsIanaRegistered && info.Source == "curated" && info.Extensions.Contains(".event_stream"));
50+
known.ShouldContain(static info => info.Mime == "application/vnd.mermaid" && info.IsIanaRegistered && info.Extensions.Contains(".mermaid"));
51+
known.ShouldContain(static info => info.Mime == "text/vnd.typst" && info.IsIanaRegistered && info.Extensions.Contains(".typ"));
3852
}
3953

4054
[Fact]

0 commit comments

Comments
 (0)