support hidden folders

This commit is contained in:
Gor Grigoryan
2025-12-24 18:52:07 +04:00
parent 4a6660813c
commit a55626c9f1
2 changed files with 32 additions and 1 deletions

View File

@@ -13,11 +13,16 @@ const MARKETPLACE_URL_REGEX =
* @returns true if the input is a local path, false if it's a URL
*/
function isLocalPath(input: string): boolean {
// Local paths start with ./, ../, /, or a drive letter (Windows)
// Local paths start with:
// - ./ or ../ (relative paths)
// - / (Unix absolute paths)
// - .something/ (hidden folders like .claude-marketplace/)
// - Drive letter (Windows paths like C:\)
return (
input.startsWith("./") ||
input.startsWith("../") ||
input.startsWith("/") ||
/^\.[a-zA-Z0-9_-]+[\\\/]/.test(input) || // Hidden folders: .plugins/, .cache/
/^[a-zA-Z]:[\\\/]/.test(input)
);
}

View File

@@ -703,4 +703,30 @@ describe("installPlugins", () => {
{ stdio: "inherit" },
);
});
test("should accept hidden folder path (.folder-name/)", async () => {
const spy = createMockSpawn();
await installPlugins(".my-plugins/marketplace", "test-plugin");
expect(spy).toHaveBeenCalledTimes(2);
expect(spy).toHaveBeenNthCalledWith(
1,
"claude",
["plugin", "marketplace", "add", ".my-plugins/marketplace"],
{ stdio: "inherit" },
);
});
test("should accept hidden folder path with Windows backslash", async () => {
const spy = createMockSpawn();
await installPlugins(".hidden-folder\\marketplace", "test-plugin");
expect(spy).toHaveBeenCalledTimes(2);
expect(spy).toHaveBeenNthCalledWith(
1,
"claude",
["plugin", "marketplace", "add", ".hidden-folder\\marketplace"],
{ stdio: "inherit" },
);
});
});