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

Function doesSourceMatchHostPattern

src/utils/plugins/marketplaceHelpers.ts:278–295  ·  view source on GitHub ↗

* Check if a source matches a hostPattern entry. * Extracts the host from the source and tests it against the regex pattern. * * @param source - The marketplace source to check * @param pattern - The hostPattern entry from strictKnownMarketplaces * @returns true if the source's host matches the

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

Source from the content-addressed store, hash-verified

276 * @returns true if the source's host matches the pattern
277 */
278function doesSourceMatchHostPattern(
279 source: MarketplaceSource,
280 pattern: MarketplaceSource & { source: 'hostPattern' },
281): boolean {
282 const host = extractHostFromSource(source)
283 if (!host) {
284 return false
285 }
286
287 try {
288 const regex = new RegExp(pattern.hostPattern)
289 return regex.test(host)
290 } catch {
291 // Invalid regex - log and return false
292 logError(new Error(`Invalid hostPattern regex: ${pattern.hostPattern}`))
293 return false
294 }
295}
296
297/**
298 * Check if a source matches a pathPattern entry.

Callers 1

isSourceAllowedByPolicyFunction · 0.85

Calls 2

extractHostFromSourceFunction · 0.85
logErrorFunction · 0.50

Tested by

no test coverage detected