MCPcopy Create free account
hub / github.com/cortexkit/magic-context / sanitizePathString

Function sanitizePathString

packages/plugin/src/shared/redaction.ts:110–124  ·  view source on GitHub ↗
(value: string)

Source from the content-addressed store, hash-verified

108}
109
110export function sanitizePathString(value: string): string {
111 const home = homedir();
112 const username = userInfo().username;
113 let sanitized = value;
114 if (home) {
115 sanitized = sanitized.replace(new RegExp(escapeRegex(home), "g"), "~");
116 }
117 sanitized = sanitized.replace(/\/Users\/[^/]+\//g, "/Users/<USER>/");
118 sanitized = sanitized.replace(/\/home\/[^/]+\//g, "/home/<USER>/");
119 sanitized = sanitized.replace(/C:\\Users\\[^\\]+\\/g, "C:\\Users\\<USER>\\");
120 if (username) {
121 sanitized = sanitized.replace(new RegExp(escapeRegex(username), "g"), "<USER>");
122 }
123 return sanitized;
124}
125
126const SECRET_TEXT_PATTERNS: Array<{
127 pattern: RegExp;

Callers 2

sanitizeStringFunction · 0.90
sanitizeDiagnosticTextFunction · 0.85

Calls 1

escapeRegexFunction · 0.70

Tested by

no test coverage detected