diff --git a/Libraries/LibWeb/DOMURL/DOMURL.cpp b/Libraries/LibWeb/DOMURL/DOMURL.cpp index a4ed162fa58..5817107b05c 100644 --- a/Libraries/LibWeb/DOMURL/DOMURL.cpp +++ b/Libraries/LibWeb/DOMURL/DOMURL.cpp @@ -215,23 +215,18 @@ String DOMURL::origin() const } // https://url.spec.whatwg.org/#dom-url-protocol -WebIDL::ExceptionOr DOMURL::protocol() const +String DOMURL::protocol() const { - auto& vm = realm().vm(); - // The protocol getter steps are to return this’s URL’s scheme, followed by U+003A (:). - return TRY_OR_THROW_OOM(vm, String::formatted("{}:", m_url.scheme())); + return MUST(String::formatted("{}:", m_url.scheme())); } // https://url.spec.whatwg.org/#ref-for-dom-url-protocol%E2%91%A0 -WebIDL::ExceptionOr DOMURL::set_protocol(String const& protocol) +void DOMURL::set_protocol(String const& protocol) { - auto& vm = realm().vm(); - // The protocol setter steps are to basic URL parse the given value, followed by U+003A (:), with this’s URL as // url and scheme start state as state override. - (void)URL::Parser::basic_parse(TRY_OR_THROW_OOM(vm, String::formatted("{}:", protocol)), {}, &m_url, URL::Parser::State::SchemeStart); - return {}; + (void)URL::Parser::basic_parse(MUST(String::formatted("{}:", protocol)), {}, &m_url, URL::Parser::State::SchemeStart); } // https://url.spec.whatwg.org/#dom-url-username @@ -271,12 +266,10 @@ void DOMURL::set_password(String const& password) } // https://url.spec.whatwg.org/#dom-url-host -WebIDL::ExceptionOr DOMURL::host() const +String DOMURL::host() const { - auto& vm = realm().vm(); - // 1. Let url be this’s URL. - auto& url = m_url; + auto const& url = m_url; // 2. If url’s host is null, then return the empty string. if (!url.host().has_value()) @@ -287,7 +280,7 @@ WebIDL::ExceptionOr DOMURL::host() const return url.serialized_host(); // 4. Return url’s host, serialized, followed by U+003A (:) and url’s port, serialized. - return TRY_OR_THROW_OOM(vm, String::formatted("{}:{}", url.serialized_host(), *url.port())); + return MUST(String::formatted("{}:{}", url.serialized_host(), *url.port())); } // https://url.spec.whatwg.org/#dom-url-hostref-for-dom-url-host%E2%91%A0 @@ -302,7 +295,7 @@ void DOMURL::set_host(String const& host) } // https://url.spec.whatwg.org/#dom-url-hostname -WebIDL::ExceptionOr DOMURL::hostname() const +String DOMURL::hostname() const { // 1. If this’s URL’s host is null, then return the empty string. if (!m_url.host().has_value()) @@ -324,16 +317,14 @@ void DOMURL::set_hostname(String const& hostname) } // https://url.spec.whatwg.org/#dom-url-port -WebIDL::ExceptionOr DOMURL::port() const +String DOMURL::port() const { - auto& vm = realm().vm(); - // 1. If this’s URL’s port is null, then return the empty string. if (!m_url.port().has_value()) return String {}; // 2. Return this’s URL’s port, serialized. - return TRY_OR_THROW_OOM(vm, String::formatted("{}", *m_url.port())); + return MUST(String::formatted("{}", *m_url.port())); } // https://url.spec.whatwg.org/#ref-for-dom-url-port%E2%91%A0 @@ -376,16 +367,14 @@ void DOMURL::set_pathname(String const& pathname) } // https://url.spec.whatwg.org/#dom-url-search -WebIDL::ExceptionOr DOMURL::search() const +String DOMURL::search() const { - auto& vm = realm().vm(); - // 1. If this’s URL’s query is either null or the empty string, then return the empty string. if (!m_url.query().has_value() || m_url.query()->is_empty()) return String {}; // 2. Return U+003F (?), followed by this’s URL’s query. - return TRY_OR_THROW_OOM(vm, String::formatted("?{}", *m_url.query())); + return MUST(String::formatted("?{}", *m_url.query())); } // https://url.spec.whatwg.org/#ref-for-dom-url-search%E2%91%A0 @@ -431,16 +420,14 @@ GC::Ref DOMURL::search_params() const } // https://url.spec.whatwg.org/#dom-url-hash -WebIDL::ExceptionOr DOMURL::hash() const +String DOMURL::hash() const { - auto& vm = realm().vm(); - // 1. If this’s URL’s fragment is either null or the empty string, then return the empty string. if (!m_url.fragment().has_value() || m_url.fragment()->is_empty()) return String {}; // 2. Return U+0023 (#), followed by this’s URL’s fragment. - return TRY_OR_THROW_OOM(vm, String::formatted("#{}", m_url.fragment())); + return MUST(String::formatted("#{}", m_url.fragment())); } // https://url.spec.whatwg.org/#ref-for-dom-url-hash%E2%91%A0 diff --git a/Libraries/LibWeb/DOMURL/DOMURL.h b/Libraries/LibWeb/DOMURL/DOMURL.h index 40201c9267b..9d150eef12f 100644 --- a/Libraries/LibWeb/DOMURL/DOMURL.h +++ b/Libraries/LibWeb/DOMURL/DOMURL.h @@ -37,8 +37,8 @@ public: String origin() const; - WebIDL::ExceptionOr protocol() const; - WebIDL::ExceptionOr set_protocol(String const&); + String protocol() const; + void set_protocol(String const&); String const& username() const; void set_username(String const&); @@ -46,13 +46,13 @@ public: String const& password() const; void set_password(String const&); - WebIDL::ExceptionOr host() const; + String host() const; void set_host(String const&); - WebIDL::ExceptionOr hostname() const; + String hostname() const; void set_hostname(String const&); - WebIDL::ExceptionOr port() const; + String port() const; void set_port(String const&); String pathname() const; @@ -67,12 +67,12 @@ public: // FIXME: Reimplement this to meet the definition in https://url.spec.whatwg.org/#url-opaque-path once we modernize URL to meet the spec. bool cannot_be_a_base_url() const { return m_url.cannot_be_a_base_url(); } - WebIDL::ExceptionOr search() const; + String search() const; void set_search(String const&); GC::Ref search_params() const; - WebIDL::ExceptionOr hash() const; + String hash() const; void set_hash(String const&); String to_json() const;