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

Function isSubPath

packages/node-runtime/src/data-dir-switch.ts:77–83  ·  view source on GitHub ↗
(parent: string, child: string)

Source from the content-addressed store, hash-verified

75}
76
77function isSubPath(parent: string, child: string): boolean {
78 const parentPath = normalizePathForCompare(parent)
79 const childPath = normalizePathForCompare(child)
80
81 if (parentPath === childPath) return false
82 return childPath.startsWith(`${parentPath}${path.sep}`)
83}
84
85function isPathSafe(targetPath: string): boolean {
86 const normalizedTarget = targetPath.toLowerCase().replace(/\//g, '\\')

Callers 1

createNodeDataDirSwitchFunction · 0.70

Calls 1

normalizePathForCompareFunction · 0.70

Tested by

no test coverage detected