AK+LibURL: Move AK::URL into a new URL library

This URL library ends up being a relatively fundamental base library of
the system, as LibCore depends on LibURL.

This change has two main benefits:
 * Moving AK back more towards being an agnostic library that can
   be used between the kernel and userspace. URL has never really fit
   that description - and is not used in the kernel.
 * URL _should_ depend on LibUnicode, as it needs punnycode support.
   However, it's not really possible to do this inside of AK as it can't
   depend on any external library. This change brings us a little closer
   to being able to do that, but unfortunately we aren't there quite
   yet, as the code generators depend on LibCore.
This commit is contained in:
Shannon Booth
2024-03-18 16:22:27 +13:00
committed by Tim Flynn
parent 21bfa001b1
commit e800605ad3
403 changed files with 1336 additions and 1305 deletions

View File

@@ -8,7 +8,7 @@
#pragma once
#include <AK/URL.h>
#include <LibURL/URL.h>
#include <LibWeb/Bindings/PlatformObject.h>
#include <LibWeb/DOMURL/URLSearchParams.h>
#include <LibWeb/WebIDL/ExceptionOr.h>
@@ -20,7 +20,7 @@ class DOMURL : public Bindings::PlatformObject {
JS_DECLARE_ALLOCATOR(DOMURL);
public:
[[nodiscard]] static JS::NonnullGCPtr<DOMURL> create(JS::Realm&, URL, JS::NonnullGCPtr<URLSearchParams> query);
[[nodiscard]] static JS::NonnullGCPtr<DOMURL> create(JS::Realm&, URL::URL, JS::NonnullGCPtr<URLSearchParams> query);
static WebIDL::ExceptionOr<JS::NonnullGCPtr<DOMURL>> construct_impl(JS::Realm&, String const& url, Optional<String> const& base = {});
virtual ~DOMURL() override;
@@ -79,22 +79,22 @@ public:
void set_query(Badge<URLSearchParams>, Optional<String> query) { m_url.set_query(move(query)); }
private:
DOMURL(JS::Realm&, URL, JS::NonnullGCPtr<URLSearchParams> query);
DOMURL(JS::Realm&, URL::URL, JS::NonnullGCPtr<URLSearchParams> query);
virtual void initialize(JS::Realm&) override;
virtual void visit_edges(Cell::Visitor&) override;
URL m_url;
URL::URL m_url;
JS::NonnullGCPtr<URLSearchParams> m_query;
};
HTML::Origin url_origin(URL const&);
HTML::Origin url_origin(URL::URL const&);
bool host_is_domain(URL::Host const&);
// https://url.spec.whatwg.org/#potentially-strip-trailing-spaces-from-an-opaque-path
void strip_trailing_spaces_from_an_opaque_path(DOMURL& url);
// https://url.spec.whatwg.org/#concept-url-parser
URL parse(StringView input, Optional<URL> const& base_url = {});
URL::URL parse(StringView input, Optional<URL::URL> const& base_url = {});
}