mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 20:29:18 +00:00
LibWeb: Make MimeSniff::MimeType::parse() infallible
It already returns an empty Optional for failures, so there's no need to wrap it in an ErrorOr as well.
This commit is contained in:
parent
88e7688940
commit
5c20bc2afc
Notes:
github-actions[bot]
2024-10-14 18:48:45 +00:00
Author: https://github.com/awesomekling
Commit: 5c20bc2afc
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1796
15 changed files with 39 additions and 37 deletions
|
@ -204,7 +204,7 @@ JS::NonnullGCPtr<Blob> Blob::create(JS::Realm& realm, Optional<Vector<BlobPart>>
|
|||
|
||||
// NOTE: The spec is out of date, and we are supposed to call into the MimeType parser here.
|
||||
if (!options->type.is_empty()) {
|
||||
auto maybe_parsed_type = MUST(Web::MimeSniff::MimeType::parse(options->type));
|
||||
auto maybe_parsed_type = Web::MimeSniff::MimeType::parse(options->type);
|
||||
|
||||
if (maybe_parsed_type.has_value())
|
||||
type = maybe_parsed_type->serialized();
|
||||
|
|
|
@ -62,7 +62,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<File>> File::create(JS::Realm& realm, Vecto
|
|||
// FIXME: 2. Convert every character in t to ASCII lowercase.
|
||||
|
||||
// NOTE: The spec is out of date, and we are supposed to call into the MimeType parser here.
|
||||
auto maybe_parsed_type = MUST(Web::MimeSniff::MimeType::parse(options->type));
|
||||
auto maybe_parsed_type = Web::MimeSniff::MimeType::parse(options->type);
|
||||
|
||||
if (maybe_parsed_type.has_value())
|
||||
type = maybe_parsed_type->serialized();
|
||||
|
|
|
@ -86,8 +86,8 @@ WebIDL::ExceptionOr<FileReader::Result> FileReader::blob_package_data(JS::Realm&
|
|||
auto maybe_type = MimeSniff::MimeType::parse(mime_type.value());
|
||||
|
||||
// 2. If type is not failure, set encoding to the result of getting an encoding from type’s parameters["charset"].
|
||||
if (!maybe_type.is_error() && maybe_type.value().has_value()) {
|
||||
auto type = maybe_type.release_value().value();
|
||||
if (maybe_type.has_value()) {
|
||||
auto const& type = maybe_type.value();
|
||||
auto it = type.parameters().find("charset"sv);
|
||||
if (it != type.parameters().end())
|
||||
encoding = TextCodec::get_standardized_encoding(it->value);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue