Skip to content

Commit 53cb6c9

Browse files
committed
fix: tighten home display path boundary
1 parent 4bba46e commit 53cb6c9

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

‎packages/terminal-core/src/display-string.test.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,8 @@ describe("displayString", () => {
2323
`path=${path.join("$OPENCLAW_HOME", "project")}`,
2424
);
2525
expect(displayString(`${home}ice${path.sep}project`)).toBe(`${home}ice${path.sep}project`);
26+
expect(displayString(`${home}+logs`)).toBe(`${home}+logs`);
27+
expect(displayString(`${home}@logs`)).toBe(`${home}@logs`);
28+
expect(displayString(`${home}:logs`)).toBe(`${home}:logs`);
2629
});
2730
});

‎packages/terminal-core/src/display-string.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,12 @@ function hasPathBoundaryBefore(input: string, index: number): boolean {
8181
return index === 0 || !isPathSegmentChar(input[index - 1]);
8282
}
8383

84+
function isPathSeparator(char: string | undefined): boolean {
85+
return char === "/" || char === "\\";
86+
}
87+
8488
function hasPathBoundaryAfter(input: string, index: number): boolean {
85-
return index >= input.length || !isPathSegmentChar(input[index]);
89+
return index >= input.length || isPathSeparator(input[index]);
8690
}
8791

8892
function replaceHomePath(input: string, home: string, prefix: string): string {

0 commit comments

Comments
 (0)