LibWeb/MimeSniff: Add MimeType::is_archive()

This commit is contained in:
Kemal Zebari 2023-09-19 23:46:31 -07:00 committed by Sam Atkins
parent 99a47b9276
commit 644cc1d7ee
2 changed files with 11 additions and 0 deletions

View file

@ -284,6 +284,16 @@ bool MimeType::is_zip_based() const
return subtype().ends_with_bytes("+zip"sv) || essence().is_one_of("application/zip"sv);
}
// https://mimesniff.spec.whatwg.org/#archive-mime-type
bool MimeType::is_archive() const
{
// An archive MIME type is any MIME type whose essence is one of the following:
// - application/x-rar-compressed
// - application/zip
// - application/x-gzip
return essence().is_one_of("application/x-rar-compressed"sv, "application/zip"sv, "application/x-gzip"sv);
}
// https://mimesniff.spec.whatwg.org/#xml-mime-type
bool MimeType::is_xml() const
{

View file

@ -30,6 +30,7 @@ public:
bool is_audio_or_video() const;
bool is_font() const;
bool is_zip_based() const;
bool is_archive() const;
bool is_xml() const;
bool is_html() const;
bool is_javascript() const;