mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-07-02 00:10:58 -05:00
fix: guess mimeType when uri is DataURI and mimeType is empty
This commit is contained in:
parent
e7e494f5a9
commit
7e482e1bfe
|
|
@ -397,6 +397,24 @@ namespace UniGLTF
|
|||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
// for Data URI
|
||||
if (uri.StartsWith("data:", StringComparison.Ordinal))
|
||||
{
|
||||
var headerEnd = uri.IndexOf(',');
|
||||
if (headerEnd < 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
const int dataPrefixLength = 5; // "data:".Length
|
||||
var header = uri[dataPrefixLength..headerEnd];
|
||||
var semicolonPos = header.IndexOf(';');
|
||||
var mime = semicolonPos >= 0 ? header[..semicolonPos] : header;
|
||||
|
||||
return mime is "image/png" or "image/jpeg" ? mime : null;
|
||||
}
|
||||
|
||||
var ext = System.IO.Path.GetExtension(uri).ToLowerInvariant();
|
||||
switch (ext)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user