mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 12:47:35 +00:00
LibWeb/MimeSniff: Add MimeType::is_json()
This commit is contained in:
parent
b110e4649e
commit
355e373ce5
2 changed files with 8 additions and 0 deletions
|
@ -335,4 +335,11 @@ bool MimeType::is_javascript() const
|
|||
"text/x-javascript"sv);
|
||||
}
|
||||
|
||||
// https://mimesniff.spec.whatwg.org/#json-mime-type
|
||||
bool MimeType::is_json() const
|
||||
{
|
||||
// A JSON MIME type is any MIME type whose subtype ends in "+json" or whose essence is "application/json" or "text/json".
|
||||
return subtype().ends_with_bytes("+json"sv) || essence().is_one_of("application/json"sv, "text/json"sv);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -35,6 +35,7 @@ public:
|
|||
bool is_html() const;
|
||||
bool is_scriptable() const;
|
||||
bool is_javascript() const;
|
||||
bool is_json() const;
|
||||
|
||||
ErrorOr<void> set_parameter(String name, String value);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue