MCPcopy
hub / github.com/mixedbread-ai/mgrep / isAtOrAboveHomeDirectory

Function isAtOrAboveHomeDirectory

src/lib/utils.ts:64–82  ·  view source on GitHub ↗
(targetPath: string)

Source from the content-addressed store, hash-verified

62 * @returns true if the path is at or above home directory, false if it's a subdirectory of home
63 */
64export function isAtOrAboveHomeDirectory(targetPath: string): boolean {
65 const homeDir = os.homedir();
66 const resolvedTarget = path.resolve(targetPath);
67 const resolvedHome = path.resolve(homeDir);
68
69 if (resolvedTarget === resolvedHome) {
70 return true;
71 }
72
73 const targetWithSep = resolvedTarget.endsWith(path.sep)
74 ? resolvedTarget
75 : resolvedTarget + path.sep;
76
77 if (resolvedHome.startsWith(targetWithSep)) {
78 return true;
79 }
80
81 return false;
82}
83
84const XXHASH_PREFIX = "xxh64:";
85

Callers 2

startWatchFunction · 0.85
search.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected