1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 15:37:46 +00:00

LibWeb: Add a bare implementation of the URL built-in

This only has the constructor implemented for now.
This commit is contained in:
Idan Horowitz 2021-09-14 00:10:22 +03:00 committed by Andreas Kling
parent 30849b10d5
commit e6abc1b44e
8 changed files with 103 additions and 1 deletions

View file

@ -7,5 +7,36 @@
#pragma once
#include <AK/String.h>
#include <AK/URL.h>
#include <LibWeb/Bindings/Wrappable.h>
#include <LibWeb/DOM/ExceptionOr.h>
#include <LibWeb/URL/URLSearchParams.h>
namespace Web::URL {
class URL : public Bindings::Wrappable
, public RefCounted<URL>
, public Weakable<URL> {
public:
using WrapperType = Bindings::URLWrapper;
static NonnullRefPtr<URL> create(AK::URL url, NonnullRefPtr<URLSearchParams> query)
{
return adopt_ref(*new URL(move(url), move(query)));
}
static DOM::ExceptionOr<NonnullRefPtr<URL>> create_with_global_object(Bindings::WindowObject&, const String& url, const String& base);
void set_query(Badge<URLSearchParams>, String query) { m_url.set_query(move(query)); }
private:
explicit URL(AK::URL url, NonnullRefPtr<URLSearchParams> query)
: m_url(move(url))
, m_query(move(query)) {};
AK::URL m_url;
NonnullRefPtr<URLSearchParams> m_query;
};
}