diff --git a/HTTP/MIMEType.cs b/HTTP/MIMEType.cs index 415b1a0..b9aa3c3 100644 --- a/HTTP/MIMEType.cs +++ b/HTTP/MIMEType.cs @@ -3,6 +3,8 @@ using System.Text.Json.Serialization; namespace Uwaa.HTTP; +//TODO: Add support for parameters + /// /// Represents a Multipurpose Internet Mail Extensions type, which indicates the nature and format of a document/file/chunk of data. /// @@ -44,6 +46,10 @@ public readonly record struct MIMEType throw new FormatException("The provided MIME type is missing a subtype."); } + int end = text.IndexOf(';'); + if (end == -1) + end = text.Length; + if (spl == 1 && text[0] == '*') Type = null; else @@ -52,7 +58,7 @@ public readonly record struct MIMEType if (spl == text.Length - 2 && text[^1] == '*') Subtype = null; else - Subtype = new string(text[(spl + 1)..]); + Subtype = new string(text[(spl + 1)..end]); } ///