mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-06 16:19:23 +00:00
LibURL+LibWeb: Make URL::serialize return a String
Simplifying a bunch of uneeded error handling around the place.
This commit is contained in:
parent
d7ac0601ab
commit
0fa54c2327
Notes:
github-actions[bot]
2024-12-04 16:48:13 +00:00
Author: https://github.com/shannonbooth
Commit: 0fa54c2327
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2727
Reviewed-by: https://github.com/AtkinsSJ ✅
52 changed files with 88 additions and 103 deletions
|
@ -245,7 +245,7 @@ String URL::serialize_path() const
|
|||
}
|
||||
|
||||
// https://url.spec.whatwg.org/#concept-url-serializer
|
||||
ByteString URL::serialize(ExcludeFragment exclude_fragment) const
|
||||
String URL::serialize(ExcludeFragment exclude_fragment) const
|
||||
{
|
||||
// 1. Let output be url’s scheme and U+003A (:) concatenated.
|
||||
StringBuilder output;
|
||||
|
@ -307,7 +307,7 @@ ByteString URL::serialize(ExcludeFragment exclude_fragment) const
|
|||
}
|
||||
|
||||
// 7. Return output.
|
||||
return output.to_byte_string();
|
||||
return output.to_string_without_validation();
|
||||
}
|
||||
|
||||
// https://url.spec.whatwg.org/#url-rendering
|
||||
|
@ -353,19 +353,12 @@ ByteString URL::serialize_for_display() const
|
|||
return builder.to_byte_string();
|
||||
}
|
||||
|
||||
ErrorOr<String> URL::to_string() const
|
||||
{
|
||||
return String::from_byte_string(serialize());
|
||||
}
|
||||
|
||||
// https://url.spec.whatwg.org/#concept-url-origin
|
||||
Origin URL::origin() const
|
||||
{
|
||||
// The origin of a URL url is the origin returned by running these steps, switching on url’s scheme:
|
||||
// -> "blob"
|
||||
if (scheme() == "blob"sv) {
|
||||
auto url_string = to_string().release_value_but_fixme_should_propagate_errors();
|
||||
|
||||
// 1. If url’s blob URL entry is non-null, then return url’s blob URL entry’s environment’s origin.
|
||||
if (blob_url_entry().has_value())
|
||||
return blob_url_entry()->environment_origin;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue