Allow unmodified regexes
AntonioRedondo opened this issue · 1 comments
Hi Rich,
It looks like the handling of strings to replace doesn't work well for all cases.
For example:
replace({
delimiters: ["", ""],
"/* buildDev:start */[\s\S]*/* buildDev:end */": ""
}),
fails when searching for matches because the escape()
function transforms the pattern to \/\* buildDev:start \*\/\[\\s\\S\]\+\/\* buildDev:end \*\/
. The escaping function doesn't take into account character classes like \s
or \S
, whose \
character shouldn't be escaped.
In order to address this issue we have two possible solutions:
- Creating a more complex
escape()
function which properly handles character classes. - Allowing the user to use untouched (and already escaped) regexes, that is it, apply patterns without the plugin modifying them at all –unlike it happens now, where patters are always escaped–.
If we consider the last solution –which in my opinion is the simplest and most powerful one–, the implementation of it wouldn't be much of a trouble. It would be creating a new flag of the kind unmodifiedRegexes: true
on the plugin configuration and then assign the patterns unmodified to pattern
around line 34.
If you agree with me this is a good idea I don't mind to make a pull request with the new feature and updated tests and docs.
Hey folks. This is a saved-form message, but rest assured we mean every word. The Rollup team is attempting to clean up the Issues backlog in the hopes that the active and still-needed, still-relevant issues bubble up to the surface. With that, we're closing issues that have been open for an eon or two, and have gone stale like pirate hard-tack without activity.
We really appreciate the folks have taken the time to open and comment on this issue. Please don't confuse this closure with us not caring or dismissing your issue, feature request, discussion, or report. The issue will still be here, just in a closed state. If the issue pertains to a bug, please re-test for the bug on the latest version of Rollup and if present, please tag @wesleygrimes and request a re-open, and we'll be happy to oblige.