Skip to content

Commit

Permalink
fix test implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
anonrig committed Jan 7, 2025
1 parent 3f5b3e6 commit f75ed01
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion include/ada/url_pattern.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<bool> test(const url_pattern_input& input, std::string_view* base_url);

/**
* @see https://urlpattern.spec.whatwg.org/#url-pattern-match
Expand Down
4 changes: 2 additions & 2 deletions src/url_pattern.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ result<std::optional<url_pattern_result>> url_pattern::exec(
return match(input, base_url);
}

bool url_pattern::test(const url_pattern_input& input,
result<bool> 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.
Expand All @@ -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<std::optional<url_pattern_result>> url_pattern::match(
Expand Down

0 comments on commit f75ed01

Please sign in to comment.