Closed
Description
The code below will assign the created RegExp
to options.search
, in webpack2, the options.search
will be reused for next file processing. So, the RegExp will be another one other than the first one expected.
function processOptions(source, options) {
if (!_.isUndefined(options.search) && !_.isUndefined(options.replace)) {
if (!_.isUndefined(options.flags)) {
options.search = new RegExp(options.search, options.flags);
}
var newSource = source.replace(options.search, options.replace);
if (options.strict && (newSource === source)) {
throw new Error('Cannot replace ' + options.search + ' → ' + options.replace);
}
} else if (options.strict) {
throw new Error('Cannot replace: undefined search or/and option(s) → ' + JSON.stringify(options));
}
return newSource;
}
Metadata
Metadata
Assignees
Labels
No labels