MCPcopy Index your code
hub / github.com/ChatLab/ChatLab / isSubPath

Function isSubPath

apps/desktop/main/utils/pathUtils.ts:34–40  ·  view source on GitHub ↗
(parent: string, child: string)

Source from the content-addressed store, hash-verified

32 * 判断 child 是否为 parent 的子目录
33 */
34export function isSubPath(parent: string, child: string): boolean {
35 const parentPath = normalizePathForCompare(parent)
36 const childPath = normalizePathForCompare(child)
37
38 if (parentPath === childPath) return false
39 return childPath.startsWith(`${parentPath}${path.sep}`)
40}
41
42/**
43 * 检查路径是否安全(不在系统关键目录下)

Callers 1

setCustomDataDirFunction · 0.90

Calls 1

normalizePathForCompareFunction · 0.70

Tested by

no test coverage detected