mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 10:18:11 +00:00
LibWeb/MimeSniff: Rename MimeType::from_string() to MimeType::parse()
This matches the spec's "parse a MIME type".
This commit is contained in:
parent
65ab6d3b6f
commit
fabea2a6a7
5 changed files with 7 additions and 7 deletions
|
@ -322,7 +322,7 @@ Optional<MimeSniff::MimeType> HeaderList::extract_mime_type() const
|
|||
// 6. For each value of values:
|
||||
for (auto const& value : *values) {
|
||||
// 1. Let temporaryMimeType be the result of parsing value.
|
||||
auto temporary_mime_type = MimeSniff::MimeType::from_string(value);
|
||||
auto temporary_mime_type = MimeSniff::MimeType::parse(value);
|
||||
|
||||
// 2. If temporaryMimeType is failure or its essence is "*/*", then continue.
|
||||
if (!temporary_mime_type.has_value() || temporary_mime_type->essence() == "*/*"sv)
|
||||
|
@ -457,7 +457,7 @@ bool is_cors_safelisted_request_header(Header const& header)
|
|||
return false;
|
||||
|
||||
// 2. Let mimeType be the result of parsing the result of isomorphic decoding value.
|
||||
auto mime_type = MimeSniff::MimeType::from_string(StringView { value });
|
||||
auto mime_type = MimeSniff::MimeType::parse(StringView { value });
|
||||
|
||||
// 3. If mimeType is failure, then return false.
|
||||
if (!mime_type.has_value())
|
||||
|
|
|
@ -218,7 +218,7 @@ void HTMLObjectElement::resource_did_load()
|
|||
|
||||
static bool is_xml_mime_type(StringView resource_type)
|
||||
{
|
||||
auto mime_type = MimeSniff::MimeType::from_string(resource_type);
|
||||
auto mime_type = MimeSniff::MimeType::parse(resource_type);
|
||||
if (!mime_type.has_value())
|
||||
return false;
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ namespace Web::MimeSniff {
|
|||
bool is_javascript_mime_type_essence_match(DeprecatedString const& string)
|
||||
{
|
||||
// NOTE: The mime type parser automatically lowercases the essence.
|
||||
auto type = MimeType::from_string(string);
|
||||
auto type = MimeType::parse(string);
|
||||
if (!type.has_value())
|
||||
return false;
|
||||
return type->is_javascript();
|
||||
|
@ -64,7 +64,7 @@ static bool contains_only_http_token_code_points(StringView string)
|
|||
}
|
||||
|
||||
// https://mimesniff.spec.whatwg.org/#parse-a-mime-type
|
||||
Optional<MimeType> MimeType::from_string(StringView string)
|
||||
Optional<MimeType> MimeType::parse(StringView string)
|
||||
{
|
||||
// 1. Remove any leading and trailing HTTP whitespace from input.
|
||||
auto trimmed_string = string.trim(Fetch::Infrastructure::HTTP_WHITESPACE, TrimMode::Both);
|
||||
|
|
|
@ -17,7 +17,7 @@ bool is_javascript_mime_type_essence_match(DeprecatedString const&);
|
|||
// https://mimesniff.spec.whatwg.org/#mime-type
|
||||
class MimeType {
|
||||
public:
|
||||
static Optional<MimeType> from_string(StringView);
|
||||
static Optional<MimeType> parse(StringView);
|
||||
|
||||
MimeType(DeprecatedString type, DeprecatedString subtype);
|
||||
~MimeType();
|
||||
|
|
|
@ -610,7 +610,7 @@ WebIDL::ExceptionOr<void> XMLHttpRequest::override_mime_type(DeprecatedString co
|
|||
return WebIDL::InvalidStateError::create(realm(), "Cannot override MIME type when state is Loading or Done.");
|
||||
|
||||
// 2. Set this’s override MIME type to the result of parsing mime.
|
||||
m_override_mime_type = MimeSniff::MimeType::from_string(mime);
|
||||
m_override_mime_type = MimeSniff::MimeType::parse(mime);
|
||||
|
||||
// 3. If this’s override MIME type is failure, then set this’s override MIME type to application/octet-stream.
|
||||
if (!m_override_mime_type.has_value())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue