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

Method globToRegex

src/mcp/tools.ts:8959–8967  ·  view source on GitHub ↗

* Convert glob pattern to regex

(pattern: string)

Source from the content-addressed store, hash-verified

8957 * Convert glob pattern to regex
8958 */
8959 private globToRegex(pattern: string): RegExp {
8960 const escaped = pattern
8961 .replace(/[.+^${}()|[\]\\]/g, '\\$&') // Escape special regex chars except * and ?
8962 .replace(/\*\*/g, '{{GLOBSTAR}}') // Temp placeholder for **
8963 .replace(/\*/g, '[^/]*') // * matches anything except /
8964 .replace(/\?/g, '[^/]') // ? matches single char except /
8965 .replace(/\{\{GLOBSTAR\}\}/g, '.*'); // ** matches anything including /
8966 return new RegExp(escaped);
8967 }
8968
8969 /**
8970 * Format files as a flat list

Callers 1

handleFilesMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected