MCPcopy
hub / github.com/jestjs/jest / replacePathSepForRegex

Function replacePathSepForRegex

packages/jest-regex-util/src/index.ts:23–31  ·  view source on GitHub ↗
(string: string)

Source from the content-addressed store, hash-verified

21 string.replaceAll(/[$()*+.?[\\\]^{|}]/g, '\\$&');
22
23export const replacePathSepForRegex = (string: string): string => {
24 if (sep === '\\') {
25 return string.replaceAll(
26 /(\/|(.)?\\(?![$()*+.?[\\\]^{|}]))/g,
27 (_match, _, p2) => (p2 && p2 !== '\\' ? `${p2}\\\\` : '\\\\'),
28 );
29 }
30 return string;
31};

Callers 6

ValidConfig.tsFile · 0.90
Defaults.tsFile · 0.90
isMatchMethod · 0.90
escapePathForRegexFunction · 0.70
index.test.tsFile · 0.50

Calls

no outgoing calls

Tested by

no test coverage detected