LibWeb/MimeSniff: Add MimeType::is_font()
This commit is contained in:
parent
3a0fa0e471
commit
75c42258f2
Notes:
sideshowbarker
2024-07-17 03:35:24 +09:00
Author: https://github.com/kemzeb Commit: https://github.com/SerenityOS/serenity/commit/75c42258f2 Pull-request: https://github.com/SerenityOS/serenity/pull/21165 Reviewed-by: https://github.com/AtkinsSJ ✅
2 changed files with 25 additions and 0 deletions
|
@ -252,6 +252,30 @@ bool MimeType::is_audio_or_video() const
|
|||
return type().is_one_of("audio"sv, "video"sv) || essence() == "application/ogg"sv;
|
||||
}
|
||||
|
||||
// https://mimesniff.spec.whatwg.org/#font-mime-type
|
||||
bool MimeType::is_font() const
|
||||
{
|
||||
// A font MIME type is any MIME type whose type is "font", or whose essence is one of the following:
|
||||
// - application/font-cff
|
||||
// - application/font-off
|
||||
// - application/font-sfnt
|
||||
// - application/font-ttf
|
||||
// - application/font-woff
|
||||
// - application/vnd.ms-fontobject
|
||||
// - application/vnd.ms-opentype
|
||||
if (type() == "font"sv)
|
||||
return true;
|
||||
|
||||
return essence().is_one_of(
|
||||
"application/font-cff"sv,
|
||||
"application/font-off"sv,
|
||||
"application/font-sfnt"sv,
|
||||
"application/font-ttf"sv,
|
||||
"application/font-woff"sv,
|
||||
"application/vnd.ms-fontobject"sv,
|
||||
"application/vnd.ms-opentype"sv);
|
||||
}
|
||||
|
||||
// https://mimesniff.spec.whatwg.org/#xml-mime-type
|
||||
bool MimeType::is_xml() const
|
||||
{
|
||||
|
|
|
@ -28,6 +28,7 @@ public:
|
|||
|
||||
bool is_image() const;
|
||||
bool is_audio_or_video() const;
|
||||
bool is_font() const;
|
||||
bool is_xml() const;
|
||||
bool is_html() const;
|
||||
bool is_javascript() const;
|
||||
|
|
Loading…
Add table
Reference in a new issue