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

LibWeb: Consistently use the EmptyString state of ReferrerPolicy

We previously used an empty optional to denote that a ReferrerPolicy is
in the default empty string state. However, later additions added an
explicit EmptyString state. This patch moves all users to the explicit
state, and stops using `Optional<ReferrerPolicy>` everywhere except for
when an option not being passed from JavaScript has meaning.
This commit is contained in:
Andrew Kaster 2024-03-05 09:35:25 -07:00 committed by Andreas Kling
parent 637f2f2ed6
commit c79bac70f4
12 changed files with 23 additions and 24 deletions

View file

@ -82,8 +82,8 @@ Optional<URL> determine_requests_referrer(Fetch::Infrastructure::Request const&
// 8. Execute the statements corresponding to the value of policy:
// Note: If requests referrer policy is the empty string, Fetch will not call into this algorithm.
VERIFY(policy.has_value());
switch (*policy) {
VERIFY(policy != ReferrerPolicy::EmptyString);
switch (policy) {
// "no-referrer"
case ReferrerPolicy::NoReferrer:
// Return no referrer

View file

@ -35,6 +35,8 @@ StringView to_string(ReferrerPolicy referrer_policy)
Optional<ReferrerPolicy> from_string(StringView string)
{
if (string.is_empty())
return ReferrerPolicy::EmptyString;
if (string.equals_ignoring_ascii_case("no-referrer"sv))
return ReferrerPolicy::NoReferrer;
if (string.equals_ignoring_ascii_case("no-referrer-when-downgrade"sv))