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

Method globToRegex

src/mcp/tools.ts:4242–4250  ·  view source on GitHub ↗

* Convert glob pattern to regex

(pattern: string)

Source from the content-addressed store, hash-verified

4240 * Convert glob pattern to regex
4241 */
4242 private globToRegex(pattern: string): RegExp {
4243 const escaped = pattern
4244 .replace(/[.+^${}()|[\]\\]/g, '\\$&') // Escape special regex chars except * and ?
4245 .replace(/\*\*/g, '{{GLOBSTAR}}') // Temp placeholder for **
4246 .replace(/\*/g, '[^/]*') // * matches anything except /
4247 .replace(/\?/g, '[^/]') // ? matches single char except /
4248 .replace(/\{\{GLOBSTAR\}\}/g, '.*'); // ** matches anything including /
4249 return new RegExp(escaped);
4250 }
4251
4252 /**
4253 * Format files as a flat list

Callers 1

handleFilesMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected