diff --git a/Userland/Libraries/LibWeb/HTML/CORSSettingAttribute.cpp b/Userland/Libraries/LibWeb/HTML/CORSSettingAttribute.cpp
index 6eee57613d..097a4cadf2 100644
--- a/Userland/Libraries/LibWeb/HTML/CORSSettingAttribute.cpp
+++ b/Userland/Libraries/LibWeb/HTML/CORSSettingAttribute.cpp
@@ -26,4 +26,24 @@ CORSSettingAttribute cors_setting_attribute_from_keyword(Optional const&
return CORSSettingAttribute::Anonymous;
}
+// https://html.spec.whatwg.org/multipage/urls-and-fetching.html#cors-settings-attribute-credentials-mode
+Fetch::Infrastructure::Request::CredentialsMode cors_settings_attribute_credentials_mode(CORSSettingAttribute attribute)
+{
+ switch (attribute) {
+ // -> No CORS
+ // -> Anonymous
+ case CORSSettingAttribute::NoCORS:
+ case CORSSettingAttribute::Anonymous:
+ // "same-origin"
+ return Fetch::Infrastructure::Request::CredentialsMode::SameOrigin;
+
+ // -> Use Credentials
+ case CORSSettingAttribute::UseCredentials:
+ // "include"
+ return Fetch::Infrastructure::Request::CredentialsMode::Include;
+ }
+
+ VERIFY_NOT_REACHED();
+}
+
}
diff --git a/Userland/Libraries/LibWeb/HTML/CORSSettingAttribute.h b/Userland/Libraries/LibWeb/HTML/CORSSettingAttribute.h
index 5d60e13052..73ea94eeee 100644
--- a/Userland/Libraries/LibWeb/HTML/CORSSettingAttribute.h
+++ b/Userland/Libraries/LibWeb/HTML/CORSSettingAttribute.h
@@ -8,6 +8,7 @@
#include
#include
+#include
namespace Web::HTML {
@@ -19,5 +20,6 @@ enum class CORSSettingAttribute {
};
[[nodiscard]] CORSSettingAttribute cors_setting_attribute_from_keyword(Optional const& keyword);
+[[nodiscard]] Fetch::Infrastructure::Request::CredentialsMode cors_settings_attribute_credentials_mode(CORSSettingAttribute);
}