Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add pluggable regex engine support #837

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

anonrig
Copy link
Member

@anonrig anonrig commented Jan 10, 2025

This is a proposal. Not meant to be merged as it is.

The goal is to have an abstract class under ada::url_pattern_regex::provider, where any application can implement their own class that inherits from this provider class. Later, we will use this abstract method class methods inside the URLPattern to enable Node.js like applications to not depend on std::regex.

By default, we will create a std_regex_provider class that inherits from provider to test our changes locally.

Any feedback is welcome.

cc @lemire @jasnell @mikea

@lemire
Copy link
Member

lemire commented Jan 10, 2025

Sounds like a good idea!

std::optional<type> create_regex_instance(std::string_view pattern,
bool ignore_case);

std::optional<std::vector<std::string>> regex_search(std::string_view input, std::string_view pattern);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall this looks fine. I'm not entirely in love with the std::optional<std::vector<...>> part but can live with it.

@jasnell
Copy link
Contributor

jasnell commented Jan 10, 2025

Definite +1 on the idea. The only key requirement is that in practical use, it will be necessary for implementations using V8 to acquire the lock on the isolate if it doesn't have it already. Just worth keeping in mind when considering the overhead here.

I would make sure that the API allows passing in a void* argument as "user data" that is passed back to the callback when it is invoked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants