Files
openclaw/src/infra/path-safety.ts
2026-02-22 17:11:54 +00:00

12 lines
385 B
TypeScript

import path from "node:path";
import { isPathInside } from "./path-guards.js";
export function resolveSafeBaseDir(rootDir: string): string {
const resolved = path.resolve(rootDir);
return resolved.endsWith(path.sep) ? resolved : `${resolved}${path.sep}`;
}
export function isWithinDir(rootDir: string, targetPath: string): boolean {
return isPathInside(rootDir, targetPath);
}