mirror of
https://github.com/RGBCube/serenity
synced 2025-06-01 11:08:12 +00:00
LibWeb: Make Web::URL::host_is_domain accept an AK::URL::Host
Which allows us to avoid serializing the host only to try and reparse it again as either an IPv4 or IPv6 address.
This commit is contained in:
parent
8751be09f9
commit
3cb65645cf
3 changed files with 4 additions and 6 deletions
|
@ -256,7 +256,7 @@ WebIDL::ExceptionOr<Optional<JS::NonnullGCPtr<PendingResponse>>> main_fetch(JS::
|
||||||
// - request’s current URL’s scheme is "http"
|
// - request’s current URL’s scheme is "http"
|
||||||
request->current_url().scheme() == "http"sv
|
request->current_url().scheme() == "http"sv
|
||||||
// - request’s current URL’s host is a domain
|
// - request’s current URL’s host is a domain
|
||||||
&& URL::host_is_domain(request->current_url().serialized_host().release_value_but_fixme_should_propagate_errors())
|
&& URL::host_is_domain(request->current_url().host())
|
||||||
// FIXME: - Matching request’s current URL’s host per Known HSTS Host Domain Name Matching results in either a
|
// FIXME: - Matching request’s current URL’s host per Known HSTS Host Domain Name Matching results in either a
|
||||||
// superdomain match with an asserted includeSubDomains directive or a congruent match (with or without an
|
// superdomain match with an asserted includeSubDomains directive or a congruent match (with or without an
|
||||||
// asserted includeSubDomains directive) [HSTS]; or DNS resolution for the request finds a matching HTTPS RR
|
// asserted includeSubDomains directive) [HSTS]; or DNS resolution for the request finds a matching HTTPS RR
|
||||||
|
|
|
@ -482,12 +482,10 @@ HTML::Origin url_origin(AK::URL const& url)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://url.spec.whatwg.org/#concept-domain
|
// https://url.spec.whatwg.org/#concept-domain
|
||||||
bool host_is_domain(StringView host)
|
bool host_is_domain(AK::URL::Host const& host)
|
||||||
{
|
{
|
||||||
// A domain is a non-empty ASCII string that identifies a realm within a network.
|
// A domain is a non-empty ASCII string that identifies a realm within a network.
|
||||||
return !host.is_empty()
|
return host.has<String>() && host.get<String>() != String {};
|
||||||
&& !IPv4Address::from_string(host).has_value()
|
|
||||||
&& !IPv6Address::from_string(host).has_value();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://url.spec.whatwg.org/#concept-url-parser
|
// https://url.spec.whatwg.org/#concept-url-parser
|
||||||
|
|
|
@ -75,7 +75,7 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
HTML::Origin url_origin(AK::URL const&);
|
HTML::Origin url_origin(AK::URL const&);
|
||||||
bool host_is_domain(StringView host);
|
bool host_is_domain(AK::URL::Host const&);
|
||||||
|
|
||||||
// https://url.spec.whatwg.org/#concept-url-parser
|
// https://url.spec.whatwg.org/#concept-url-parser
|
||||||
AK::URL parse(StringView input, Optional<AK::URL> const& base_url = {});
|
AK::URL parse(StringView input, Optional<AK::URL> const& base_url = {});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue