Skip to content

Commit b2c323a

Browse files
fix: normalize staged artifact paths on windows
1 parent 0608338 commit b2c323a

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

src/scan-target/helpers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export function sanitizePathSegment(value: string): string {
5858

5959
export function preserveTailSegments(pathname: string, count: number): string {
6060
const segments = pathname
61-
.split("/")
61+
.split(/[\\/]+/u)
6262
.filter((segment) => segment.length > 0)
6363
.map((segment) => sanitizePathSegment(segment));
6464
if (segments.length === 0) {

tests/scan-target-helpers.test.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
inferToolFromReportPath,
99
isLikelyGitRepoUrl,
1010
parseGitHubFileSource,
11+
preserveTailSegments,
1112
shouldStageContainingFolder,
1213
} from "../src/scan-target/helpers";
1314

@@ -63,6 +64,12 @@ describe("scan target helpers", () => {
6364
expect(shouldStageContainingFolder("/tmp/repo/README.md")).toBe(false);
6465
});
6566

67+
it("preserves trailing path segments for Windows-style paths", () => {
68+
expect(
69+
preserveTailSegments("D:\\tmp\\repo\\skills\\security-review", 2).replaceAll("\\", "/"),
70+
).toBe("skills/security-review");
71+
});
72+
6673
it("infers formats and tools for explicit artifact candidates", () => {
6774
expect(inferTextLikeFormat("skills/demo/SKILL.md")).toBe("markdown");
6875
expect(inferTextLikeFormat(".cursor/rules/review.mdc")).toBe("markdown");

0 commit comments

Comments
 (0)