MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / globToRegex

Method globToRegex

src/mcp/tools.ts:6570–6578  ·  view source on GitHub ↗

* Convert glob pattern to regex

(pattern: string)

Source from the content-addressed store, hash-verified

6568 * Convert glob pattern to regex
6569 */
6570 private globToRegex(pattern: string): RegExp {
6571 const escaped = pattern
6572 .replace(/[.+^${}()|[\]\\]/g, '\\$&') // Escape special regex chars except * and ?
6573 .replace(/\*\*/g, '{{GLOBSTAR}}') // Temp placeholder for **
6574 .replace(/\*/g, '[^/]*') // * matches anything except /
6575 .replace(/\?/g, '[^/]') // ? matches single char except /
6576 .replace(/\{\{GLOBSTAR\}\}/g, '.*'); // ** matches anything including /
6577 return new RegExp(escaped);
6578 }
6579
6580 /**
6581 * Format files as a flat list

Callers 1

handleFilesMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected