LibWeb/LibURL: Use an IgnoreCase enum for URLPatternOptions

This is to save a future name conflict that will appear between
the options IDL dictionary and the options struct that are both
present in the spec.

It is also a nicer interface for now given there is only a single
option at the moment.
This commit is contained in:
Shannon Booth 2025-03-18 20:09:47 +13:00 committed by Tim Flynn
commit 8a33c57c1e
Notes: github-actions[bot] 2025-04-06 12:28:11 +00:00
4 changed files with 14 additions and 9 deletions

View file

@ -10,7 +10,7 @@
namespace URL::Pattern {
// https://urlpattern.spec.whatwg.org/#url-pattern-create
PatternErrorOr<Pattern> Pattern::create(Input const& input, Optional<String> const& base_url, Options const&)
PatternErrorOr<Pattern> Pattern::create(Input const& input, Optional<String> const& base_url, IgnoreCase)
{
// 1. Let init be null.
Init init;

View file

@ -19,11 +19,6 @@ namespace URL::Pattern {
// https://urlpattern.spec.whatwg.org/#typedefdef-urlpatterninput
using Input = Variant<String, Init>;
// https://urlpattern.spec.whatwg.org/#dictdef-urlpatternoptions
struct Options {
bool ignore_case { false };
};
// https://urlpattern.spec.whatwg.org/#dictdef-urlpatterncomponentresult
struct ComponentResult {
String input;
@ -44,10 +39,16 @@ struct Result {
ComponentResult hash;
};
// https://urlpattern.spec.whatwg.org/#dictdef-urlpatternoptions
enum class IgnoreCase {
Yes,
No,
};
// https://urlpattern.spec.whatwg.org/#url-pattern
class Pattern {
public:
static PatternErrorOr<Pattern> create(Input const&, Optional<String> const& base_url = {}, Options const& = {});
static PatternErrorOr<Pattern> create(Input const&, Optional<String> const& base_url = {}, IgnoreCase = IgnoreCase::No);
PatternErrorOr<Optional<Result>> match(Input const&, Optional<String> const& base_url_string) const;