1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-14 09:34:59 +00:00

AK: Move URL::cannot_have_a_username_or_password_or_port out of line

This doesn't seem trivial enough to be defining in the header like this,
and should not be a performance critical function anyhow.

Also add spec comments while we are at it, and a FIXME since we do not
seem to exactly align.
This commit is contained in:
Shannon Booth 2023-07-26 20:54:36 +12:00 committed by Andreas Kling
parent 0c0117fc86
commit a1ae701a7d
2 changed files with 9 additions and 1 deletions

View file

@ -152,6 +152,14 @@ void URL::set_fragment(DeprecatedString fragment, ApplyPercentEncoding apply_per
m_fragment = move(fragment);
}
// https://url.spec.whatwg.org/#cannot-have-a-username-password-port
bool URL::cannot_have_a_username_or_password_or_port() const
{
// A URL cannot have a username/password/port if its host is null or the empty string, or its scheme is "file".
// FIXME: The spec does not mention anything to do with 'cannot be a base URL'.
return m_host.is_null() || m_host.is_empty() || m_cannot_be_a_base_url || m_scheme == "file"sv;
}
// FIXME: This is by no means complete.
// NOTE: This relies on some assumptions about how the spec-defined URL parser works that may turn out to be wrong.
bool URL::compute_validity() const