File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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, " "),
Original file line number Diff line number Diff 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 ( ) ;
You can’t perform that action at this time.
0 commit comments