mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 13:38:11 +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
|
@ -482,12 +482,10 @@ HTML::Origin url_origin(AK::URL const& url)
|
|||
}
|
||||
|
||||
// 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.
|
||||
return !host.is_empty()
|
||||
&& !IPv4Address::from_string(host).has_value()
|
||||
&& !IPv6Address::from_string(host).has_value();
|
||||
return host.has<String>() && host.get<String>() != String {};
|
||||
}
|
||||
|
||||
// https://url.spec.whatwg.org/#concept-url-parser
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue