MCPcopy
hub / github.com/vitest-dev/vitest / parseRegexp

Function parseRegexp

packages/browser/src/client/public/esm-client-injector.js:56–69  ·  view source on GitHub ↗
(input)

Source from the content-addressed store, hash-verified

54 config.retry.condition = parseRegexp(config.retry.condition);
55
56 function parseRegexp(input) {
57 // Parse input
58 const m = input.match(/(\/?)(.+)\1([a-z]*)/i);
59
60 // match nothing
61 if (!m) return /$^/;
62
63 // Invalid flags
64 if (m[3] && !/^(?!.*?(.).*?\1)[gmixXsuUAJ]+$/.test(m[3]))
65 return RegExp(input);
66
67 // Create the regular expression
68 return new RegExp(m[2], m[3]);
69 }
70})();

Callers 1

Calls 2

matchMethod · 0.45
testMethod · 0.45

Tested by

no test coverage detected