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

Function matchesCommand

src/tools/PowerShellTool/powershellPermissions.ts:223–245  ·  view source on GitHub ↗
(cmd: string)

Source from the content-addressed store, hash-verified

221 // Also resolve the rule's command name to canonical for cross-matching
222 // e.g., a deny rule for 'rm' should also block 'Remove-Item'
223 function matchesCommand(cmd: string): boolean {
224 switch (rule.type) {
225 case 'exact':
226 return strEquals(rule.command, cmd)
227 case 'prefix':
228 switch (matchMode) {
229 case 'exact':
230 return strEquals(rule.prefix, cmd)
231 case 'prefix': {
232 if (strEquals(cmd, rule.prefix)) {
233 return true
234 }
235 return strStartsWith(cmd, rule.prefix + ' ')
236 }
237 }
238 break
239 case 'wildcard':
240 if (matchMode === 'exact') {
241 return false
242 }
243 return matchWildcardPattern(rule.pattern, cmd, true)
244 }
245 }
246
247 // Check against the original command
248 if (matchesCommand(command)) {

Callers 1

Calls 3

strEqualsFunction · 0.85
strStartsWithFunction · 0.85
matchWildcardPatternFunction · 0.50

Tested by

no test coverage detected