mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-26 04:35:41 +03: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:
parent
0c0117fc86
commit
a1ae701a7d
Notes:
sideshowbarker
2024-07-18 03:23:00 +09:00
Author: https://github.com/shannonbooth Commit: https://github.com/SerenityOS/serenity/commit/a1ae701a7d Pull-request: https://github.com/SerenityOS/serenity/pull/20245 Reviewed-by: https://github.com/kennethmyhra ✅
@ -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
|
||||
|
2
AK/URL.h
2
AK/URL.h
@ -89,7 +89,7 @@ public:
|
||||
|
||||
u16 port_or_default() const { return m_port.value_or(default_port_for_scheme(m_scheme)); }
|
||||
bool cannot_be_a_base_url() const { return m_cannot_be_a_base_url; }
|
||||
bool cannot_have_a_username_or_password_or_port() const { return m_host.is_null() || m_host.is_empty() || m_cannot_be_a_base_url || m_scheme == "file"sv; }
|
||||
bool cannot_have_a_username_or_password_or_port() const;
|
||||
|
||||
bool includes_credentials() const { return !m_username.is_empty() || !m_password.is_empty(); }
|
||||
bool is_special() const { return is_special_scheme(m_scheme); }
|
||||
|
Loading…
Reference in New Issue
Block a user