2021-09-13 00:33:23 +03:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2021, Idan Horowitz <idan.horowitz@serenityos.org>
|
|
|
|
|
* Copyright (c) 2021, the SerenityOS developers.
|
|
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2022-12-04 18:02:33 +00:00
|
|
|
#include <AK/DeprecatedString.h>
|
2021-09-14 00:10:22 +03:00
|
|
|
#include <AK/URL.h>
|
2022-09-04 14:04:42 +02:00
|
|
|
#include <LibWeb/Bindings/PlatformObject.h>
|
2021-09-14 00:10:22 +03:00
|
|
|
#include <LibWeb/URL/URLSearchParams.h>
|
2022-09-25 17:03:42 +01:00
|
|
|
#include <LibWeb/WebIDL/ExceptionOr.h>
|
2021-09-14 00:10:22 +03:00
|
|
|
|
2021-09-13 00:33:23 +03:00
|
|
|
namespace Web::URL {
|
2021-09-14 00:10:22 +03:00
|
|
|
|
2022-09-04 14:04:42 +02:00
|
|
|
class URL : public Bindings::PlatformObject {
|
|
|
|
|
WEB_PLATFORM_OBJECT(URL, Bindings::PlatformObject);
|
2021-09-14 00:10:22 +03:00
|
|
|
|
2022-09-04 14:04:42 +02:00
|
|
|
public:
|
LibWeb: Remove unecessary dependence on Window from assorted classes
These classes only needed Window to get at its realm. Pass a realm
directly to construct Crypto, Encoding, HRT, IntersectionObserver,
NavigationTiming, Page, RequestIdleCallback, Selection, Streams, URL,
and XML classes.
2022-09-25 18:11:21 -06:00
|
|
|
static JS::NonnullGCPtr<URL> create(JS::Realm&, AK::URL url, JS::NonnullGCPtr<URLSearchParams> query);
|
2022-12-04 18:02:33 +00:00
|
|
|
static WebIDL::ExceptionOr<JS::NonnullGCPtr<URL>> construct_impl(JS::Realm&, DeprecatedString const& url, DeprecatedString const& base);
|
2021-09-14 00:10:22 +03:00
|
|
|
|
2022-09-04 14:04:42 +02:00
|
|
|
virtual ~URL() override;
|
2021-09-14 00:10:22 +03:00
|
|
|
|
2022-12-04 18:02:33 +00:00
|
|
|
DeprecatedString href() const;
|
|
|
|
|
WebIDL::ExceptionOr<void> set_href(DeprecatedString const&);
|
2021-09-14 00:13:32 +03:00
|
|
|
|
2022-12-04 18:02:33 +00:00
|
|
|
DeprecatedString origin() const;
|
2021-09-14 00:18:25 +03:00
|
|
|
|
2022-12-04 18:02:33 +00:00
|
|
|
DeprecatedString protocol() const;
|
|
|
|
|
void set_protocol(DeprecatedString const&);
|
2021-09-14 00:21:51 +03:00
|
|
|
|
2022-12-04 18:02:33 +00:00
|
|
|
DeprecatedString username() const;
|
|
|
|
|
void set_username(DeprecatedString const&);
|
2021-09-14 00:18:25 +03:00
|
|
|
|
2022-12-04 18:02:33 +00:00
|
|
|
DeprecatedString password() const;
|
|
|
|
|
void set_password(DeprecatedString const&);
|
2021-09-14 00:18:25 +03:00
|
|
|
|
2022-12-04 18:02:33 +00:00
|
|
|
DeprecatedString host() const;
|
|
|
|
|
void set_host(DeprecatedString const&);
|
2021-09-14 00:21:29 +03:00
|
|
|
|
2022-12-04 18:02:33 +00:00
|
|
|
DeprecatedString hostname() const;
|
|
|
|
|
void set_hostname(DeprecatedString const&);
|
2021-09-14 00:21:29 +03:00
|
|
|
|
2022-12-04 18:02:33 +00:00
|
|
|
DeprecatedString port() const;
|
|
|
|
|
void set_port(DeprecatedString const&);
|
2021-09-14 00:21:29 +03:00
|
|
|
|
2022-12-04 18:02:33 +00:00
|
|
|
DeprecatedString pathname() const;
|
|
|
|
|
void set_pathname(DeprecatedString const&);
|
2021-09-14 00:21:51 +03:00
|
|
|
|
2022-12-04 18:02:33 +00:00
|
|
|
DeprecatedString search() const;
|
|
|
|
|
void set_search(DeprecatedString const&);
|
2021-09-14 00:21:51 +03:00
|
|
|
|
2021-09-14 00:15:41 +03:00
|
|
|
URLSearchParams const* search_params() const;
|
|
|
|
|
|
2022-12-04 18:02:33 +00:00
|
|
|
DeprecatedString hash() const;
|
|
|
|
|
void set_hash(DeprecatedString const&);
|
2021-09-14 00:21:51 +03:00
|
|
|
|
2022-12-04 18:02:33 +00:00
|
|
|
DeprecatedString to_json() const;
|
2021-09-14 00:13:32 +03:00
|
|
|
|
2022-12-04 18:02:33 +00:00
|
|
|
void set_query(Badge<URLSearchParams>, DeprecatedString query) { m_url.set_query(move(query)); }
|
2021-09-14 00:10:22 +03:00
|
|
|
|
|
|
|
|
private:
|
LibWeb: Remove unecessary dependence on Window from assorted classes
These classes only needed Window to get at its realm. Pass a realm
directly to construct Crypto, Encoding, HRT, IntersectionObserver,
NavigationTiming, Page, RequestIdleCallback, Selection, Streams, URL,
and XML classes.
2022-09-25 18:11:21 -06:00
|
|
|
URL(JS::Realm&, AK::URL, JS::NonnullGCPtr<URLSearchParams> query);
|
2022-09-04 14:04:42 +02:00
|
|
|
|
2023-01-28 12:33:35 -05:00
|
|
|
virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override;
|
2022-09-04 14:04:42 +02:00
|
|
|
virtual void visit_edges(Cell::Visitor&) override;
|
2021-09-14 00:10:22 +03:00
|
|
|
|
|
|
|
|
AK::URL m_url;
|
2022-09-04 14:04:42 +02:00
|
|
|
JS::NonnullGCPtr<URLSearchParams> m_query;
|
2021-09-14 00:10:22 +03:00
|
|
|
};
|
|
|
|
|
|
2022-10-13 18:25:00 +02:00
|
|
|
HTML::Origin url_origin(AK::URL const&);
|
2022-10-13 18:26:35 +02:00
|
|
|
bool host_is_domain(StringView host);
|
2022-10-13 18:25:00 +02:00
|
|
|
|
2021-09-13 00:33:23 +03:00
|
|
|
}
|