Skip to content

Commit 31b5755

Browse files
committed
Show trailing-separator scan path names
1 parent 3bf2621 commit 31b5755

2 files changed

Lines changed: 24 additions & 1 deletion

File tree

sdk/typescript/src/cli.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2877,7 +2877,7 @@ function scanScope(arguments_: ScanArguments): string | null {
28772877
isAbsolute(path) ||
28782878
/^[A-Za-z]:\//u.test(portable) ||
28792879
portable.startsWith("//")
2880-
? portable.split("/").at(-1) ?? portable
2880+
? basename(portable) || portable
28812881
: portable;
28822882
return redactedErrorMessage(
28832883
scoped.replaceAll(/[\u0000-\u001F\u007F]/gu, " "),

sdk/typescript/tests-ts/cli.test.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2538,6 +2538,29 @@ describe("CLI", () => {
25382538
expect(stderr.text()).not.toContain("% complete");
25392539
});
25402540

2541+
test("preserves directory names for absolute scan paths with trailing separators", async () => {
2542+
const stdout = capture();
2543+
const stderr = capture();
2544+
2545+
expect(
2546+
await main(
2547+
[
2548+
"scan",
2549+
".",
2550+
"--path",
2551+
"/synthetic-parent/trailing-directory/",
2552+
"--json",
2553+
],
2554+
stdout.stream,
2555+
stderr.stream,
2556+
dependencies(),
2557+
),
2558+
).toBe(0);
2559+
expect(JSON.parse(stdout.text())).toEqual(fakeResult().toJSON());
2560+
expect(stderr.text()).toContain("Running scan: trailing-directory");
2561+
expect(stderr.text()).not.toContain("synthetic-parent");
2562+
});
2563+
25412564
test("prints a truthful completion summary without changing JSON results", async () => {
25422565
const stdout = capture();
25432566
const stderr = capture();

0 commit comments

Comments
 (0)