mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 10:48:11 +00:00
LibWeb: Implement 'create a potential-CORS request' algorithm
This commit is contained in:
parent
3e2e94bd01
commit
f7176463b5
6 changed files with 122 additions and 0 deletions
29
Userland/Libraries/LibWeb/HTML/CORSSettingAttribute.cpp
Normal file
29
Userland/Libraries/LibWeb/HTML/CORSSettingAttribute.cpp
Normal file
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
* Copyright (c) 2023, Srikavin Ramkumar <me@srikavin.me>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibWeb/HTML/CORSSettingAttribute.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/urls-and-fetching.html#cors-settings-attributes
|
||||
CORSSettingAttribute cors_setting_attribute_from_keyword(Optional<String> const& keyword)
|
||||
{
|
||||
if (!keyword.has_value()) {
|
||||
// its missing value default is the No CORS state
|
||||
return CORSSettingAttribute::NoCORS;
|
||||
}
|
||||
if (keyword->is_empty() || keyword->bytes_as_string_view().equals_ignoring_ascii_case("anonymous"sv)) {
|
||||
return CORSSettingAttribute::Anonymous;
|
||||
}
|
||||
if (keyword->bytes_as_string_view().equals_ignoring_ascii_case("use-credentials"sv)) {
|
||||
return CORSSettingAttribute::UseCredentials;
|
||||
}
|
||||
|
||||
// The attribute's invalid value default is the Anonymous state
|
||||
return CORSSettingAttribute::Anonymous;
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue