-
Notifications
You must be signed in to change notification settings - Fork 683
Open
Description
Quoting Wikipedia:
Types, subtypes, and parameter names are case-insensitive. Parameter values are usually case-sensitive, but may be interpreted in a case-insensitive fashion depending on the intended use.[6]
E.g. for text/plain;charset=UTF-8 everything but UTF-8 is case-insensitive and UTF-8 might be treated case-insensitive.
Unfortunately, ImageFormat::from_mime_type does not respect this and uses a case-sensitive comparison.
Lines 150 to 157 in 4c05148
| pub fn from_mime_type<M>(mime_type: M) -> Option<Self> | |
| where | |
| M: AsRef<str>, | |
| { | |
| match mime_type.as_ref() { | |
| "image/avif" => Some(ImageFormat::Avif), | |
| "image/jpeg" => Some(ImageFormat::Jpeg), | |
| "image/png" => Some(ImageFormat::Png), |
It would probably be easiest to just lower-case everything and treat everything as case-insensitive.
Expected
assert_eq!(ImageFormat::from_mime_type("IMAGE/PNG"), Some(ImageFormat::Png));Actual behaviour
assert_eq!(ImageFormat::from_mime_type("IMAGE/PNG"), None);Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels