Open JJ opened 11 months ago
Thanks for making this github action!
Just wondering if you rexify by escaping: https://github.com/JJ/github-pr-contains-action/commit/6f56b9f5452bf0cc363db66b884d03a12ef8c73f
Could you just "reverse" the meaning of the escape?
so \s\ would be the original regex \s
Assuming that would be okay, you could just process the expression twice.
["(", ")", "[", "]", "?", "+", "*"].forEach((s) => {
expression = expression.replace(s, `\\${s}`);
});
["\\\\(", "\\\\)", "\\\\[", "\\\\]", "\\\\?", "\\\\+", "\\\\*"].forEach((s) => {
expression = expression.replace(s, `${s.slice(-1)}`);
});
return new RegExp(expression);
Thanks for the suggestion. I drew myself into a corner here. I think that the solution will rather be to use a different parameter for regexes, so that it keeps compatibility, maybe together with a deprecation cycle.
Right now it's tricky, since strings are rexified; it's probably better to add new features for checking real regexes. You can code alternatives into regexes, so using several ones might not be it.