MCPcopy Create free account
hub / github.com/codeaashu/claude-code / urlPatternToRegex

Function urlPatternToRegex

src/services/mcp/config.ts:320–326  ·  view source on GitHub ↗

* Convert a URL pattern with wildcards to a RegExp * Supports * as wildcard matching any characters * Examples: * "https://example.com/*" matches "https://example.com/api/v1" * "https://*.example.com/*" matches "https://api.example.com/path" * "https://example.com:*\/*" matches any port

(pattern: string)

Source from the content-addressed store, hash-verified

318 * "https://example.com:*\/*" matches any port
319 */
320function urlPatternToRegex(pattern: string): RegExp {
321 // Escape regex special characters except *
322 const escaped = pattern.replace(/[.+?^${}()|[\]\\]/g, '\\$&')
323 // Replace * with regex equivalent (match any characters)
324 const regexStr = escaped.replace(/\*/g, '.*')
325 return new RegExp(`^${regexStr}$`)
326}
327
328/**
329 * Check if a URL matches a pattern with wildcard support

Callers 1

urlMatchesPatternFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected