openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
12 lines (11 loc) • 551 B
JavaScript
//#region src/infra/approval-display-paths.ts
/** Formats user-home paths compactly for approval prompts without normalizing unsafe paths. */
function formatApprovalDisplayPath(e) {
const t = e.trim();
if (!t || /(^|[\\/])\.{1,2}(?=[\\/]|$)/.test(t)) return t;
const n = t.match(/^\/(?:home|Users)\/([^/]+)(.*)$/) ?? t.match(/^[A-Za-z]:[\\/]Users[\\/]([^\\/]+)(.*)$/i);
const r = n?.[1];
return n && r !== void 0 && r !== "." && r !== ".." ? `~${(n[2] ?? "").replaceAll("\\", "/")}` : t;
}
//#endregion
export { formatApprovalDisplayPath as t };