fix: recognize Windows absolute drive paths (C:\...) in isLocalPath#139
fix: recognize Windows absolute drive paths (C:\...) in isLocalPath#139Mordris wants to merge 2 commits intoluongnv89:mainfrom
Conversation
747248e to
b14e0cb
Compare
|
thank you very much for the PR, |
I think these are previous failures. Working on it. |
could be, i am still in the mid of cooking =)) |
luongnv89
left a comment
There was a problem hiding this comment.
Code Review — PR #139
Thanks for the fix! The core change in isLocalPath() is correct. I found one bug and added related test coverage below.
Bug: ~\ paths not expanded in parseLocalSource()
isLocalPath() correctly returns true for ~\skills\my-skill, but parseLocalSource() only handles ~/ (not ~\):
// current
} else if (input.startsWith("~/")) {
absPath = resolve(homedir(), input.slice(2));
// should be
} else if (input.startsWith("~/") || input.startsWith("~\\")) {
absPath = resolve(homedir(), input.slice(2));Without this fix, ~\skills\my-skill falls into the else branch and resolve() treats ~ as a literal directory name, producing a wrong path like C:\cwd\~\skills\my-skill.
Missing test
Add a test for the ~\ case in parseLocalSource:
test("parses tilde-backslash path", () => {
const result = parseLocalSource("~\\skills\\my-skill");
expect(result.isLocal).toBe(true);
expect(result.localPath).not.toContain("~");
});And in parseSource with local paths:
test("detects and parses tilde-backslash path", () => {
const result = parseSource("~\\my-skill");
expect(result.isLocal).toBe(true);
expect(result.localPath).not.toContain("~");
});CI failures
The CI failures (lint-and-typecheck and unit-tests) are pre-existing issues on main that your branch predates — not introduced by this PR. Rebasing onto the latest main will fix them.
Note (non-blocking)
The regex /^[a-zA-Z]:[/\\]/ is functionally correct but the / inside the character class can confuse some linters. /^[a-zA-Z]:[\\/]/ is slightly clearer.
Closes #138
Description
This PR fixes an issue where Windows absolute drive paths (e.g.,
C:\Users\...\skill) were not recognized as local sources by theasm installcommand. The logic was previously biased towards POSIX paths, causing Windows paths to be incorrectly treated as remote GitHub repositories.Related Issue
Fixes #138
Type of Change
Checklist
Screenshots (if applicable)
(Add any relevant screenshots here)
Additional Notes
The fix uses a regex
/^[a-zA-Z]:[/\\]/to identify Windows drive-letter absolute paths. This ensures compatibility with both standard backslashes and modern forward slashes in Windows environments.