1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 01:37:36 +00:00

Everywhere: Use unqualified AK::URL

Now possible in LibWeb now that there is no longer a Web::URL.
This commit is contained in:
Shannon Booth 2024-02-11 20:15:39 +13:00 committed by Andreas Kling
parent f9e5b43b7a
commit 9ce8189f21
156 changed files with 471 additions and 471 deletions

View file

@ -18,19 +18,19 @@ namespace Web::DOMURL {
JS_DEFINE_ALLOCATOR(DOMURL);
JS::NonnullGCPtr<DOMURL> DOMURL::create(JS::Realm& realm, AK::URL url, JS::NonnullGCPtr<URLSearchParams> query)
JS::NonnullGCPtr<DOMURL> DOMURL::create(JS::Realm& realm, URL url, JS::NonnullGCPtr<URLSearchParams> query)
{
return realm.heap().allocate<DOMURL>(realm, realm, move(url), move(query));
}
// https://url.spec.whatwg.org/#api-url-parser
static Optional<AK::URL> parse_api_url(String const& url, Optional<String> const& base)
static Optional<URL> parse_api_url(String const& url, Optional<String> const& base)
{
// FIXME: We somewhat awkwardly have two failure states encapsulated in the return type (and convert between them in the steps),
// ideally we'd get rid of URL's valid flag
// 1. Let parsedBase be null.
Optional<AK::URL> parsed_base;
Optional<URL> parsed_base;
// 2. If base is non-null:
if (base.has_value()) {
@ -46,7 +46,7 @@ static Optional<AK::URL> parse_api_url(String const& url, Optional<String> const
// 3. Return the result of running the basic URL parser on url with parsedBase.
auto parsed = URLParser::basic_parse(url, parsed_base);
return parsed.is_valid() ? parsed : Optional<AK::URL> {};
return parsed.is_valid() ? parsed : Optional<URL> {};
}
// https://url.spec.whatwg.org/#dom-url-url
@ -75,7 +75,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<DOMURL>> DOMURL::construct_impl(JS::Realm&
return result_url;
}
DOMURL::DOMURL(JS::Realm& realm, AK::URL url, JS::NonnullGCPtr<URLSearchParams> query)
DOMURL::DOMURL(JS::Realm& realm, URL url, JS::NonnullGCPtr<URLSearchParams> query)
: PlatformObject(realm)
, m_url(move(url))
, m_query(move(query))
@ -166,7 +166,7 @@ WebIDL::ExceptionOr<void> DOMURL::set_href(String const& href)
auto& vm = realm().vm();
// 1. Let parsedURL be the result of running the basic URL parser on the given value.
AK::URL parsed_url = href;
URL parsed_url = href;
// 2. If parsedURL is failure, then throw a TypeError.
if (!parsed_url.is_valid())
@ -355,7 +355,7 @@ WebIDL::ExceptionOr<String> DOMURL::pathname() const
auto& vm = realm().vm();
// The pathname getter steps are to return the result of URL path serializing thiss URL.
return TRY_OR_THROW_OOM(vm, String::from_byte_string(m_url.serialize_path(AK::URL::ApplyPercentDecoding::No)));
return TRY_OR_THROW_OOM(vm, String::from_byte_string(m_url.serialize_path(URL::ApplyPercentDecoding::No)));
}
// https://url.spec.whatwg.org/#ref-for-dom-url-pathname%E2%91%A0
@ -482,7 +482,7 @@ void DOMURL::set_hash(String const& hash)
}
// https://url.spec.whatwg.org/#concept-url-origin
HTML::Origin url_origin(AK::URL const& url)
HTML::Origin url_origin(URL const& url)
{
// FIXME: We should probably have an extended version of AK::URL for LibWeb instead of standalone functions like this.
@ -533,7 +533,7 @@ HTML::Origin url_origin(AK::URL const& url)
}
// https://url.spec.whatwg.org/#concept-domain
bool host_is_domain(AK::URL::Host const& host)
bool host_is_domain(URL::Host const& host)
{
// A domain is a non-empty ASCII string that identifies a realm within a network.
return host.has<String>() && host.get<String>() != String {};
@ -563,7 +563,7 @@ void strip_trailing_spaces_from_an_opaque_path(DOMURL& url)
}
// https://url.spec.whatwg.org/#concept-url-parser
AK::URL parse(StringView input, Optional<AK::URL> const& base_url)
URL parse(StringView input, Optional<URL> const& base_url)
{
// FIXME: We should probably have an extended version of AK::URL for LibWeb instead of standalone functions like this.

View file

@ -79,22 +79,22 @@ public:
void set_query(Badge<URLSearchParams>, Optional<String> query) { m_url.set_query(move(query)); }
private:
DOMURL(JS::Realm&, AK::URL, JS::NonnullGCPtr<URLSearchParams> query);
DOMURL(JS::Realm&, URL, JS::NonnullGCPtr<URLSearchParams> query);
virtual void initialize(JS::Realm&) override;
virtual void visit_edges(Cell::Visitor&) override;
AK::URL m_url;
URL m_url;
JS::NonnullGCPtr<URLSearchParams> m_query;
};
HTML::Origin url_origin(AK::URL const&);
bool host_is_domain(AK::URL::Host const&);
HTML::Origin url_origin(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
AK::URL parse(StringView input, Optional<AK::URL> const& base_url = {});
URL parse(StringView input, Optional<URL> const& base_url = {});
}

View file

@ -55,11 +55,11 @@ ErrorOr<String> url_encode(Vector<QueryParam> const& tuples, StringView encoding
// 2. Let name be the result of running percent-encode after encoding with encoding, tuples name, the application/x-www-form-urlencoded percent-encode set, and true.
// FIXME: URLParser does not currently implement encoding.
auto name = TRY(URLParser::percent_encode_after_encoding(tuple.name, AK::URL::PercentEncodeSet::ApplicationXWWWFormUrlencoded, true));
auto name = TRY(URLParser::percent_encode_after_encoding(tuple.name, URL::PercentEncodeSet::ApplicationXWWWFormUrlencoded, true));
// 3. Let value be the result of running percent-encode after encoding with encoding, tuples value, the application/x-www-form-urlencoded percent-encode set, and true.
// FIXME: URLParser does not currently implement encoding.
auto value = TRY(URLParser::percent_encode_after_encoding(tuple.value, AK::URL::PercentEncodeSet::ApplicationXWWWFormUrlencoded, true));
auto value = TRY(URLParser::percent_encode_after_encoding(tuple.value, URL::PercentEncodeSet::ApplicationXWWWFormUrlencoded, true));
// 4. If output is not the empty string, then append U+0026 (&) to output.
if (!output.is_empty())
@ -109,8 +109,8 @@ ErrorOr<Vector<QueryParam>> url_decode(StringView input)
auto space_decoded_name = name.replace("+"sv, " "sv, ReplaceMode::All);
// 5. Let nameString and valueString be the result of running UTF-8 decode without BOM on the percent-decoding of name and value, respectively.
auto name_string = TRY(String::from_byte_string(AK::URL::percent_decode(space_decoded_name)));
auto value_string = TRY(String::from_byte_string(AK::URL::percent_decode(value)));
auto name_string = TRY(String::from_byte_string(URL::percent_decode(space_decoded_name)));
auto value_string = TRY(String::from_byte_string(URL::percent_decode(value)));
TRY(output.try_empend(move(name_string), move(value_string)));
}