Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 27 additions & 11 deletions src/installer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});

Expand Down Expand Up @@ -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", () => {
Expand Down
6 changes: 5 additions & 1 deletion src/installer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
);
}

Expand Down
Loading