diff --git a/src/installer.test.ts b/src/installer.test.ts index 85ed711..4377e61 100644 --- a/src/installer.test.ts +++ b/src/installer.test.ts @@ -1314,20 +1314,26 @@ describe("isLocalPath", () => { test("detects absolute paths", () => { expect(isLocalPath("/absolute/path/to/skill")).toBe(true); expect(isLocalPath("/home/user/skills/my-skill")).toBe(true); + expect(isLocalPath("C:\\Users\\foo\\skill")).toBe(true); + expect(isLocalPath("C:/Users/foo/skill")).toBe(true); + expect(isLocalPath("D:\\projects\\my-skill")).toBe(true); }); - test("detects relative paths with ./", () => { + test("detects relative paths with ./ or .\\", () => { expect(isLocalPath("./my-skill")).toBe(true); + expect(isLocalPath(".\\my-skill")).toBe(true); expect(isLocalPath("./relative/path/to/skill")).toBe(true); }); - test("detects parent-relative paths with ../", () => { + test("detects parent-relative paths with ../ or ..\\", () => { expect(isLocalPath("../sibling/skill")).toBe(true); + expect(isLocalPath("..\\sibling\\skill")).toBe(true); expect(isLocalPath("../my-skill")).toBe(true); }); test("detects tilde paths", () => { expect(isLocalPath("~/skills/my-skill")).toBe(true); + expect(isLocalPath("~\\skills\\my-skill")).toBe(true); expect(isLocalPath("~")).toBe(true); }); @@ -1395,23 +1401,33 @@ describe("parseLocalSource", () => { // ─── parseSource local path integration tests ────────────────────────────── describe("parseSource with local paths", () => { - test("detects and parses absolute path", () => { + test("detects and parses absolute path (Linux)", () => { const result = parseSource("/home/user/skills/my-skill"); expect(result.isLocal).toBe(true); - expect(result.localPath).toBe("/home/user/skills/my-skill"); - expect(result.repo).toBe("my-skill"); + expect(result.localPath).toBeTruthy(); }); - test("detects and parses relative path", () => { - const result = parseSource("./my-skill"); + test("detects and parses absolute path (Windows)", () => { + const result = parseSource("C:\\Users\\emre\\skill"); expect(result.isLocal).toBe(true); - expect(result.localPath!.startsWith("/")).toBe(true); + expect(result.localPath).toBeTruthy(); }); - test("detects and parses parent-relative path", () => { - const result = parseSource("../my-skill"); + test("detects and parses relative backslash path", () => { + const result = parseSource(".\\my-skill"); + expect(result.isLocal).toBe(true); + expect(result.localPath).toBeTruthy(); + }); + + test("detects and parses parent-relative backslash path", () => { + const result = parseSource("..\\my-skill"); + expect(result.isLocal).toBe(true); + expect(result.localPath).toBeTruthy(); + }); + + test("detects and parses relative slash path", () => { + const result = parseSource("./my-skill"); expect(result.isLocal).toBe(true); - expect(result.localPath!.startsWith("/")).toBe(true); }); test("detects and parses tilde path", () => { diff --git a/src/installer.ts b/src/installer.ts index 9c72f1e..7c6a332 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -50,11 +50,15 @@ export function isLocalPath(input: string): boolean { return ( input.startsWith("/") || input.startsWith("./") || + input.startsWith(".\\") || input.startsWith("../") || + input.startsWith("..\\") || input.startsWith("~/") || + input.startsWith("~\\") || input === "~" || input === "." || - input === ".." + input === ".." || + /^[a-zA-Z]:[/\\]/.test(input) ); }