mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 05:37:34 +00:00
LibWeb/MimeSniff: Add missing spec comments
This commit is contained in:
parent
965da551e3
commit
34fa49c344
1 changed files with 20 additions and 0 deletions
|
@ -19,6 +19,7 @@ namespace Web::MimeSniff {
|
||||||
// https://mimesniff.spec.whatwg.org/#javascript-mime-type-essence-match
|
// https://mimesniff.spec.whatwg.org/#javascript-mime-type-essence-match
|
||||||
bool is_javascript_mime_type_essence_match(StringView string)
|
bool is_javascript_mime_type_essence_match(StringView string)
|
||||||
{
|
{
|
||||||
|
// A string is a JavaScript MIME type essence match if it is an ASCII case-insensitive match for one of the JavaScript MIME type essence strings.
|
||||||
// NOTE: The mime type parser automatically lowercases the essence.
|
// NOTE: The mime type parser automatically lowercases the essence.
|
||||||
auto type = MimeType::parse(string).release_value_but_fixme_should_propagate_errors();
|
auto type = MimeType::parse(string).release_value_but_fixme_should_propagate_errors();
|
||||||
if (!type.has_value())
|
if (!type.has_value())
|
||||||
|
@ -298,12 +299,14 @@ bool MimeType::is_archive() const
|
||||||
// https://mimesniff.spec.whatwg.org/#xml-mime-type
|
// https://mimesniff.spec.whatwg.org/#xml-mime-type
|
||||||
bool MimeType::is_xml() const
|
bool MimeType::is_xml() const
|
||||||
{
|
{
|
||||||
|
// An XML MIME type is any MIME type whose subtype ends in "+xml" or whose essence is "text/xml" or "application/xml". [RFC7303]
|
||||||
return m_subtype.ends_with_bytes("+xml"sv) || essence().is_one_of("text/xml"sv, "application/xml"sv);
|
return m_subtype.ends_with_bytes("+xml"sv) || essence().is_one_of("text/xml"sv, "application/xml"sv);
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://mimesniff.spec.whatwg.org/#html-mime-type
|
// https://mimesniff.spec.whatwg.org/#html-mime-type
|
||||||
bool MimeType::is_html() const
|
bool MimeType::is_html() const
|
||||||
{
|
{
|
||||||
|
// An HTML MIME type is any MIME type whose essence is "text/html".
|
||||||
return essence().is_one_of("text/html"sv);
|
return essence().is_one_of("text/html"sv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -317,6 +320,23 @@ bool MimeType::is_scriptable() const
|
||||||
// https://mimesniff.spec.whatwg.org/#javascript-mime-type
|
// https://mimesniff.spec.whatwg.org/#javascript-mime-type
|
||||||
bool MimeType::is_javascript() const
|
bool MimeType::is_javascript() const
|
||||||
{
|
{
|
||||||
|
// A JavaScript MIME type is any MIME type whose essence is one of the following:
|
||||||
|
// - application/ecmascript
|
||||||
|
// - application/javascript
|
||||||
|
// - application/x-ecmascript
|
||||||
|
// - application/x-javascript
|
||||||
|
// - text/ecmascript
|
||||||
|
// - text/javascript
|
||||||
|
// - text/javascript1.0
|
||||||
|
// - text/javascript1.1
|
||||||
|
// - text/javascript1.2
|
||||||
|
// - text/javascript1.3
|
||||||
|
// - text/javascript1.4
|
||||||
|
// - text/javascript1.5
|
||||||
|
// - text/jscript
|
||||||
|
// - text/livescript
|
||||||
|
// - text/x-ecmascript
|
||||||
|
// - text/x-javascript
|
||||||
return essence().is_one_of(
|
return essence().is_one_of(
|
||||||
"application/ecmascript"sv,
|
"application/ecmascript"sv,
|
||||||
"application/javascript"sv,
|
"application/javascript"sv,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue