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

Method globToRegex

src/mcp/tools.ts:9208–9216  ·  view source on GitHub ↗

* Convert glob pattern to regex

(pattern: string)

Source from the content-addressed store, hash-verified

9206 * Convert glob pattern to regex
9207 */
9208 private globToRegex(pattern: string): RegExp {
9209 const escaped = pattern
9210 .replace(/[.+^${}()|[\]\\]/g, '\\$&') // Escape special regex chars except * and ?
9211 .replace(/\*\*/g, '{{GLOBSTAR}}') // Temp placeholder for **
9212 .replace(/\*/g, '[^/]*') // * matches anything except /
9213 .replace(/\?/g, '[^/]') // ? matches single char except /
9214 .replace(/\{\{GLOBSTAR\}\}/g, '.*'); // ** matches anything including /
9215 return new RegExp(escaped);
9216 }
9217
9218 /**
9219 * Format files as a flat list

Callers 1

handleFilesMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected