diff --git a/include/ada/url_pattern.h b/include/ada/url_pattern.h index fe2dae060..f8511e465 100644 --- a/include/ada/url_pattern.h +++ b/include/ada/url_pattern.h @@ -285,7 +285,7 @@ class url_pattern { /** * @see https://urlpattern.spec.whatwg.org/#dom-urlpattern-test */ - bool test(const url_pattern_input& input, std::string_view* base_url); + result test(const url_pattern_input& input, std::string_view* base_url); /** * @see https://urlpattern.spec.whatwg.org/#url-pattern-match diff --git a/src/url_pattern.cpp b/src/url_pattern.cpp index d4ae3aad1..666c764ee 100644 --- a/src/url_pattern.cpp +++ b/src/url_pattern.cpp @@ -519,7 +519,7 @@ result> url_pattern::exec( return match(input, base_url); } -bool url_pattern::test(const url_pattern_input& input, +result url_pattern::test(const url_pattern_input& input, std::string_view* base_url = nullptr) { // TODO: Optimization opportunity. Rather than returning `url_pattern_result` // Implement a fast path just like `can_parse()` in ada_url. @@ -529,7 +529,7 @@ bool url_pattern::test(const url_pattern_input& input, if (auto result = match(input, base_url); result.has_value()) { return result->has_value(); } - return false; + return tl::unexpected(errors::type_error); } result> url_pattern::match(