MCPcopy Index your code
hub / github.com/codeaashu/claude-code / doesSourceMatchPathPattern

Function doesSourceMatchPathPattern

src/utils/plugins/marketplaceHelpers.ts:305–321  ·  view source on GitHub ↗

* Check if a source matches a pathPattern entry. * Tests the source's .path (file and directory sources only) against the regex pattern. * * @param source - The marketplace source to check * @param pattern - The pathPattern entry from strictKnownMarketplaces * @returns true if the source's path

(
  source: MarketplaceSource,
  pattern: MarketplaceSource & { source: 'pathPattern' },
)

Source from the content-addressed store, hash-verified

303 * @returns true if the source's path matches the pattern
304 */
305function doesSourceMatchPathPattern(
306 source: MarketplaceSource,
307 pattern: MarketplaceSource & { source: 'pathPattern' },
308): boolean {
309 // Only file and directory sources have a .path to match against
310 if (source.source !== 'file' && source.source !== 'directory') {
311 return false
312 }
313
314 try {
315 const regex = new RegExp(pattern.pathPattern)
316 return regex.test(source.path)
317 } catch {
318 logError(new Error(`Invalid pathPattern regex: ${pattern.pathPattern}`))
319 return false
320 }
321}
322
323/**
324 * Get hosts from hostPattern entries in the allowlist.

Callers 1

isSourceAllowedByPolicyFunction · 0.85

Calls 1

logErrorFunction · 0.50

Tested by

no test coverage detected