-
Notifications
You must be signed in to change notification settings - Fork 24
Open
Description
It seems that an error occurs here and it recognizes the .gz as .bin. While the file has recognized it correctly. I don't know, doesn't the file have an api to get the extension directly? If I understand correctly we are actually using MIME Type mapping as an alternative.
[Fact]
public void Guess_Gzip_ReturnSameAsNative()
{
// small gzip file: https://github.com/mathiasbynens/small
byte[] s_gzipBytes =
[
0x1f, 0x8b, 0x08, 0x00, 0xae, 0x86, 0xe1, 0x5b, 0x02, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00
];
var actualMimeType = GuessMimeType(s_gzipBytes);
var actualExtension = GuessExtension(s_gzipBytes);
// $ file gzip.gz --mime
// → gzip.gz: application/gzip; charset=binary
string expectedMimeType = "application/gzip";
// $ file gzip.gz --extension
// → gzip.gz: gz/tgz/tpz/ipk/vbox-extpack/svgz
string[] expectedExtensions = [ "gz", "tgz", "tpz", "ipk", "vbox-extpack", "svgz"];
Assert.Equal(expectedMimeType, actualMimeType);
Assert.Contains(expectedExtensions, e => e == actualExtension); // ← Exception raised here
}Assert.Contains() Failure
Assert.Contains() Failure
Not found: (filter expression)
In value: String[] ["gz", "tgz", "tpz", "ipk", "vbox-extpack", ...]
at Test.UnitTest.Guess_Gzip_ReturnsSameAsNative() in .../UnitTest.cs:line 28
at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)
This is probably because MimeTypesMap — which depends on MIME types known by Apache:
Line 99 in b058232
| public static string GuessExtension(byte[] buffer) => MimeTypesMap.GetExtension(GuessMimeType(buffer)); |
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels