MCPcopy Create free account
hub / github.com/github/awesome-copilot / extractExtensionFromPattern

Function extractExtensionFromPattern

eng/generate-website-data.mjs:363–375  ·  view source on GitHub ↗

* Extract file extension from a glob pattern

(pattern)

Source from the content-addressed store, hash-verified

361 * Extract file extension from a glob pattern
362 */
363function extractExtensionFromPattern(pattern) {
364 // Match patterns like **.ts, **/*.js, *.py, etc.
365 const match = pattern.match(/\*\.(\w+)$/);
366 if (match) return `.${match[1]}`;
367
368 // Match patterns like **/*.{ts,tsx}
369 const braceMatch = pattern.match(/\*\.\{([^}]+)\}$/);
370 if (braceMatch) {
371 return braceMatch[1].split(",").map((ext) => `.${ext.trim()}`);
372 }
373
374 return null;
375}
376
377/**
378 * Generate instructions metadata

Callers 1

generateInstructionsDataFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected