MCPcopy
hub / github.com/codeaashu/claude-code / normalizePatternsToPath

Function normalizePatternsToPath

src/utils/permissions/filesystem.ts:800–826  ·  view source on GitHub ↗
(
  patternsByRoot: Map<string | null, string[]>,
  root: string,
)

Source from the content-addressed store, hash-verified

798}
799
800export function normalizePatternsToPath(
801 patternsByRoot: Map<string | null, string[]>,
802 root: string,
803): string[] {
804 // null root means the pattern can match anywhere
805 const result = new Set(patternsByRoot.get(null) ?? [])
806
807 for (const [patternRoot, patterns] of patternsByRoot.entries()) {
808 if (patternRoot === null) {
809 // already added
810 continue
811 }
812
813 // Check each pattern to see if the full path starts with our reference root
814 for (const pattern of patterns) {
815 const normalizedPattern = normalizePatternToPath({
816 patternRoot,
817 pattern,
818 rootPath: root,
819 })
820 if (normalizedPattern) {
821 result.add(normalizedPattern)
822 }
823 }
824 }
825 return Array.from(result)
826}
827
828/**
829 * Collects all deny rules for file read permissions and returns their ignore patterns

Callers 3

callFunction · 0.85
logContextMetricsFunction · 0.85
globFunction · 0.85

Calls 4

normalizePatternToPathFunction · 0.85
entriesMethod · 0.80
getMethod · 0.65
addMethod · 0.45

Tested by

no test coverage detected