MCPcopy Create free account
hub / github.com/Noumena-Network/code / normalizePatternsToPath

Function normalizePatternsToPath

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

Source from the content-addressed store, hash-verified

808}
809
810export function normalizePatternsToPath(
811 patternsByRoot: Map<string | null, string[]>,
812 root: string,
813): string[] {
814 // null root means the pattern can match anywhere
815 const result = new Set(patternsByRoot.get(null) ?? [])
816
817 for (const [patternRoot, patterns] of patternsByRoot.entries()) {
818 if (patternRoot === null) {
819 // already added
820 continue
821 }
822
823 // Check each pattern to see if the full path starts with our reference root
824 for (const pattern of patterns) {
825 const normalizedPattern = normalizePatternToPath({
826 patternRoot,
827 pattern,
828 rootPath: root,
829 })
830 if (normalizedPattern) {
831 result.add(normalizedPattern)
832 }
833 }
834 }
835 return Array.from(result)
836}
837
838/**
839 * 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.45
addMethod · 0.45

Tested by

no test coverage detected