MCPcopy Create free account
hub / github.com/anus-dev/ANUS / isSubpath

Function isSubpath

packages/core/src/utils/paths.ts:211–223  ·  view source on GitHub ↗
(parentPath: string, childPath: string)

Source from the content-addressed store, hash-verified

209 * @returns True if childPath is a subpath of parentPath, false otherwise.
210 */
211export function isSubpath(parentPath: string, childPath: string): boolean {
212 const isWindows = os.platform() === 'win32';
213 const pathModule = isWindows ? path.win32 : path;
214
215 // On Windows, path.relative is case-insensitive. On POSIX, it's case-sensitive.
216 const relative = pathModule.relative(parentPath, childPath);
217
218 return (
219 !relative.startsWith(`..${pathModule.sep}`) &&
220 relative !== '..' &&
221 !pathModule.isAbsolute(relative)
222 );
223}

Callers 3

paths.test.tsFile · 0.85
validateImportPathFunction · 0.85
validateWorkspacePathMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected