jest-regex-util
Advanced tools
Comparing version
@@ -34,3 +34,3 @@ /*! | ||
// replacePathSepForRegex will convert it back. | ||
dir = dir.replace(/\\/g, '/'); | ||
dir = dir.replaceAll('\\', '/'); | ||
} | ||
@@ -40,7 +40,7 @@ return replacePathSepForRegex(escapeStrForRegex(dir)); | ||
exports.escapePathForRegex = escapePathForRegex; | ||
const escapeStrForRegex = string => string.replace(/[[\]{}()*+?.\\^$|]/g, '\\$&'); | ||
const escapeStrForRegex = string => string.replaceAll(/[$()*+.?[\\\]^{|}]/g, '\\$&'); | ||
exports.escapeStrForRegex = escapeStrForRegex; | ||
const replacePathSepForRegex = string => { | ||
if (_path.sep === '\\') { | ||
return string.replace(/(\/|(.)?\\(?![[\]{}()*+?.^$|\\]))/g, (_match, _, p2) => p2 && p2 !== '\\' ? `${p2}\\\\` : '\\\\'); | ||
return string.replaceAll(/(\/|(.)?\\(?![$()*+.?[\\\]^{|}]))/g, (_match, _, p2) => p2 && p2 !== '\\' ? `${p2}\\\\` : '\\\\'); | ||
} | ||
@@ -47,0 +47,0 @@ return string; |
{ | ||
"name": "jest-regex-util", | ||
"version": "30.0.0-alpha.2", | ||
"version": "30.0.0-alpha.3", | ||
"repository": { | ||
@@ -30,3 +30,3 @@ "type": "git", | ||
}, | ||
"gitHead": "c04d13d7abd22e47b0997f6027886aed225c9ce4" | ||
"gitHead": "e267aff33d105399f2134bad7c8f82285104f3da" | ||
} |
4321
0.19%