-
Notifications
You must be signed in to change notification settings - Fork 14
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 option to not use re2
even if it's in the dependency tree
#28
Comments
Will fix today, thanks for the suggestion |
Hi @sindresorhus - apologies for the delay. We decided to do this in a way that wouldn't even const SafeRegExp = (() => {
try {
const RE2 = require('re2');
return typeof RE2 === 'function' ? RE2 : RegExp;
} catch {
return RegExp;
}
})(); Now instead this logic is conditionally loaded inside invocation, and if users want re2 and it's already loaded, it won't re-require it twice. This should be a much more performant solution (in terms of saving memory as well and not loading an extra library that you don't want in the first place, e.g. as you mentioned if it's already in node_modules but you don't want to use it). We are wrapping up this implementation now and will publish a version shortly and ping you back! |
v4.0.0 released with this, thank you @sindresorhus – simply pass release notes @ https://github.com/spamscanner/url-regex-safe/releases/tag/v4.0.0 note: this version now requires node v14+ |
…bump deps, modernize config
Describe the feature
I want to use this package, but I never want to use the
re2
package. However, there2
package may be innode_modules
even if I don't depend on it. So whether it's used, is out of my control.I have my own way of ensuring safety, and
re2
is problematic, as the regex it returns is not a proper RegExp instance.It would be useful with an option to force using normal
RegExp
.Checklist
The text was updated successfully, but these errors were encountered: