MCPcopy Create free account
hub / github.com/Snapchat/Valdi / createReGroup

Function createReGroup

valdi/vscode_debugger/src/common/urlUtils.ts:280–292  ·  view source on GitHub ↗
(patterns: ReadonlySet<string>)

Source from the content-addressed store, hash-verified

278};
279
280const createReGroup = (patterns: ReadonlySet<string>): string => {
281 switch (patterns.size) {
282 case 0:
283 return '';
284 case 1:
285 return patterns.values().next().value;
286 default:
287 // Prefer the more compacy [aA] form if we're only matching single
288 // characters, produce a non-capturing group otherwise.
289 const arr = [...patterns];
290 return arr.some(p => p.length > 1) ? `(?:${arr.join('|')})` : `[${arr.join('')}]`;
291 }
292};
293
294/**
295 * Converts and escape the file URL to a regular expression.

Callers 1

urlToRegexFunction · 0.85

Calls 3

valuesMethod · 0.80
nextMethod · 0.65
joinMethod · 0.45

Tested by

no test coverage detected