LibWeb: Port EnvironmentSettings URL Parsing to return Optional<URL>

This commit is contained in:
Shannon Booth 2025-02-16 14:01:09 +13:00 committed by Tim Flynn
commit 2c8dab36f3
Notes: github-actions[bot] 2025-02-19 13:03:33 +00:00
8 changed files with 25 additions and 25 deletions

View file

@ -199,11 +199,11 @@ WebIDL::ExceptionOr<void> History::shared_history_push_replace_state(JS::Value d
auto parsed_url = relevant_settings_object(*this).parse_url(url->to_byte_string());
// 2. If that fails, then throw a "SecurityError" DOMException.
if (!parsed_url.is_valid())
if (!parsed_url.has_value())
return WebIDL::SecurityError::create(realm(), "Cannot pushState or replaceState to incompatible URL"_string);
// 3. Set newURL to the resulting URL record.
new_url = parsed_url;
new_url = parsed_url.release_value();
// 4. If document cannot have its URL rewritten to newURL, then throw a "SecurityError" DOMException.
if (!can_have_its_url_rewritten(document, new_url))