mirror of
https://github.com/openclaw/openclaw.git
synced 2026-10-03 09:39:25 +00:00
fix: keep POSIX sibling paths out of home-relative CLI displays (#162800)
* test: preserve POSIX backslashes at home path boundaries * fix: preserve literal backslashes in POSIX home path displays * test: format POSIX home boundary regression
This commit is contained in:
parent
ccbd3b58f2
commit
4487ee82aa
2 changed files with 9 additions and 2 deletions
|
|
@ -10,7 +10,10 @@ export function shortenPathWithHome(
|
|||
if (input === home) {
|
||||
return prefix;
|
||||
}
|
||||
if (input.startsWith(`${home}/`) || input.startsWith(`${home}\\`)) {
|
||||
if (
|
||||
input.startsWith(`${home}/`) ||
|
||||
(process.platform === "win32" && input.startsWith(`${home}\\`))
|
||||
) {
|
||||
return `${prefix}${input.slice(home.length)}`;
|
||||
}
|
||||
if (process.platform === "win32" && path.win32.isAbsolute(input) && isPathInside(home, input)) {
|
||||
|
|
|
|||
|
|
@ -173,9 +173,13 @@ describe("shortenHomePath", () => {
|
|||
},
|
||||
);
|
||||
|
||||
it.skipIf(process.platform === "win32")("keeps POSIX home matching case-sensitive", () => {
|
||||
it.skipIf(process.platform === "win32")("preserves POSIX home path boundaries and case", () => {
|
||||
withEnv({ OPENCLAW_HOME: "/srv/OpenClaw-Home", HOME: "/home/other" }, () => {
|
||||
expect(shortenHomePath("/srv/openclaw-home/workspace")).toBe("/srv/openclaw-home/workspace");
|
||||
expect(shortenHomePath("/srv/OpenClaw-Home\\workspace")).toBe(
|
||||
"/srv/OpenClaw-Home\\workspace",
|
||||
);
|
||||
expect(shortenHomePath("/srv/OpenClaw-Home/work\\space")).toBe("$OPENCLAW_HOME/work\\space");
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue