/* * Copyright (c) 2021, Idan Horowitz * Copyright (c) 2021, the SerenityOS developers. * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include #include #include #include namespace Web::URL { class URL : public Bindings::PlatformObject { WEB_PLATFORM_OBJECT(URL, Bindings::PlatformObject); public: static JS::NonnullGCPtr create(JS::Realm&, AK::URL url, JS::NonnullGCPtr query); static WebIDL::ExceptionOr> construct_impl(JS::Realm&, DeprecatedString const& url, DeprecatedString const& base); virtual ~URL() override; DeprecatedString href() const; WebIDL::ExceptionOr set_href(DeprecatedString const&); DeprecatedString origin() const; DeprecatedString protocol() const; void set_protocol(DeprecatedString const&); DeprecatedString username() const; void set_username(DeprecatedString const&); DeprecatedString password() const; void set_password(DeprecatedString const&); DeprecatedString host() const; void set_host(DeprecatedString const&); DeprecatedString hostname() const; void set_hostname(DeprecatedString const&); DeprecatedString port() const; void set_port(DeprecatedString const&); DeprecatedString pathname() const; void set_pathname(DeprecatedString const&); DeprecatedString search() const; void set_search(DeprecatedString const&); URLSearchParams const* search_params() const; DeprecatedString hash() const; void set_hash(DeprecatedString const&); DeprecatedString to_json() const; void set_query(Badge, DeprecatedString query) { m_url.set_query(move(query)); } private: URL(JS::Realm&, AK::URL, JS::NonnullGCPtr query); virtual void visit_edges(Cell::Visitor&) override; AK::URL m_url; JS::NonnullGCPtr m_query; }; HTML::Origin url_origin(AK::URL const&); bool host_is_domain(StringView host); }