LibURL/Pattern: Implement 'compute protocol matches a special scheme'

This commit is contained in:
Shannon Booth 2025-03-18 20:25:06 +13:00 committed by Tim Flynn
parent 6b1fa3ecd0
commit e54504ad93
Notes: github-actions[bot] 2025-04-06 12:26:59 +00:00
2 changed files with 17 additions and 8 deletions

View file

@ -381,7 +381,16 @@ String ConstructorStringParser::make_a_component_string() const
// https://urlpattern.spec.whatwg.org/#compute-protocol-matches-a-special-scheme-flag
PatternErrorOr<void> ConstructorStringParser::compute_protocol_matches_a_special_scheme_flag()
{
// FIXME: Implement this.
// 1. Let protocol string be the result of running make a component string given parser.
auto protocol_string = make_a_component_string();
// 2. Let protocol component be the result of compiling a component given protocol string, canonicalize a protocol, and default options.
auto protocol_component = TRY(Component::compile(protocol_string.code_points(), canonicalize_a_protocol, Options::default_()));
// 3. If the result of running protocol component matches a special scheme given protocol component is true, then set parsers protocol matches a special scheme flag to true.
if (protocol_component_matches_a_special_scheme(protocol_component))
m_protocol_matches_a_special_scheme = true;
return {};
}