mirror of https://github.com/webpack/webpack.git
fix: strip slash for pretty regexp
This commit is contained in:
parent
dd44b206a9
commit
515c0d3cd0
|
|
@ -185,13 +185,13 @@ class ContextModule extends Module {
|
|||
|
||||
/**
|
||||
* @private
|
||||
* @param {RegExp} regexString RegExp as a string
|
||||
* @param {RegExp} regex RegExp
|
||||
* @param {boolean=} stripSlash do we need to strip a slsh
|
||||
* @returns {string} pretty RegExp
|
||||
*/
|
||||
_prettyRegExp(regexString, stripSlash = true) {
|
||||
const str = (regexString + "").replace(/!/g, "%21").replace(/\|/g, "%7C");
|
||||
return stripSlash ? str.substring(1, str.length - 1) : str;
|
||||
_prettyRegExp(regex, stripSlash = true) {
|
||||
const regexString = stripSlash ? regex.source + regex.flags : regex + "";
|
||||
return regexString.replace(/!/g, "%21").replace(/\|/g, "%7C");
|
||||
}
|
||||
|
||||
_createIdentifier() {
|
||||
|
|
|
|||
|
|
@ -7,6 +7,6 @@ it("should replace ! with %21 in the module id string of the context module", fu
|
|||
).id;
|
||||
if (typeof moduleId !== "number")
|
||||
expect(moduleId).toBe(
|
||||
"./context/issue-10969/folder lazy recursive ^(?%21file1\\.js$).*$/"
|
||||
"./context/issue-10969/folder lazy recursive ^(?%21file1\\.js$).*$i"
|
||||
);
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue