LibWeb: Return OptionalNone from DOMURL::parse on failure

This ports one more function away from needing to use the awkward
valid state of the URL class.
This commit is contained in:
Shannon Booth 2025-01-22 17:35:52 +13:00 committed by Sam Atkins
parent b81d6945dc
commit fd27eef0d1
Notes: github-actions[bot] 2025-01-22 12:34:57 +00:00
18 changed files with 63 additions and 65 deletions

View file

@ -135,12 +135,12 @@ ErrorOr<Optional<URL::URL>> Response::location_url(Optional<String> const& reque
// 3. If location is a header value, then set location to the result of parsing location with responses URL.
auto location = DOMURL::parse(location_values.first(), url());
if (!location.is_valid())
if (!location.has_value())
return Error::from_string_literal("Invalid 'Location' header URL");
// 4. If location is a URL whose fragment is null, then set locations fragment to requestFragment.
if (!location.fragment().has_value())
location.set_fragment(request_fragment);
if (!location->fragment().has_value())
location->set_fragment(request_fragment);
// 5. Return location.
return location;