UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

25 lines (24 loc) 1.43 kB
import "./fs-safe-defaults-DGE52WTl.js"; import path from "node:path"; import { hasNodeErrorCode, isNotFoundPathError, isPathInside, normalizeWindowsPathForComparison, safeStatSync } from "@openclaw/fs-safe/path"; //#region src/infra/path-guards.ts /** Returns true only when target is a descendant of root, not root itself. */ function isPathStrictlyInside(root, target) { return isPathInside(root, target) && !isPathInside(target, root); } /** * Normalize a Windows path for boundary math whose result is handed back to callers. * * Unlike `normalizeWindowsPathForComparison`, this preserves case: `path.win32.relative` * already matches roots case-insensitively, so lowercasing only corrupts the returned * relative path — and callers create files from it on a case-preserving filesystem. * Extended-length prefix stripping stays, or `\\?\`-prefixed inputs read as boundary escapes. */ function normalizeWindowsPathPreservingCase(input) { const normalized = path.win32.normalize(input); if (!normalized.startsWith("\\\\?\\")) return normalized; const withoutPrefix = normalized.slice(4); return withoutPrefix.toUpperCase().startsWith("UNC\\") ? `\\\\${withoutPrefix.slice(4)}` : withoutPrefix; } //#endregion export { normalizeWindowsPathForComparison as a, isPathStrictlyInside as i, isNotFoundPathError as n, normalizeWindowsPathPreservingCase as o, isPathInside as r, safeStatSync as s, hasNodeErrorCode as t };