Repository navigation
fix: address review findings from PR #1383 Windows path separator fix #1398
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -283,7 +283,9 @@ export async function fetchFiles(params: FetchParams): Promise<FetchSummary> { | |||||||||||||||
|
|
||||||||||||||||
| // Resolve options | ||||||||||||||||
| const resolvedRef = options.ref ?? parsed.ref; | ||||||||||||||||
| const resolvedPath = options.path ?? parsed.path ?? "."; | ||||||||||||||||
| // Normalize backslashes to forward slashes for GitHub API compatibility. | ||||||||||||||||
| // On Windows, paths may contain backslashes which are invalid in API requests. | ||||||||||||||||
| const resolvedPath = (options.path ?? parsed.path ?? ".").replace(/\\/g, "/"); | ||||||||||||||||
|
||||||||||||||||
| const resolvedPath = (options.path ?? parsed.path ?? ".").replace(/\\/g, "/"); | |
| let resolvedPath = (options.path ?? parsed.path ?? ".").replace(/\\/g, "/"); | |
| // Trim leading/trailing slashes so base paths are in a consistent form. | |
| resolvedPath = resolvedPath.replace(/^\/+|\/+$/g, ""); | |
| if (resolvedPath === "") { | |
| resolvedPath = "."; | |
| } |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -143,6 +143,10 @@ export abstract class AiDir { | |||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| getRelativePathFromCwd(): string { | ||||||||||||||||||||
| // Use path.join + replace instead of path.posix.join because input segments | ||||||||||||||||||||
| // (relativeDirPath, dirName) may already contain backslashes on Windows. | ||||||||||||||||||||
| // path.posix.join does not normalize backslashes, so we must use path.join | ||||||||||||||||||||
| // (which handles OS-native separators) and then normalize to POSIX format. | ||||||||||||||||||||
|
||||||||||||||||||||
| // Use path.join + replace instead of path.posix.join because input segments | |
| // (relativeDirPath, dirName) may already contain backslashes on Windows. | |
| // path.posix.join does not normalize backslashes, so we must use path.join | |
| // (which handles OS-native separators) and then normalize to POSIX format. | |
| // Use path.join + replace instead of path.posix.join because relativeDirPath | |
| // may already contain backslashes on Windows. dirName is validated to be a | |
| // simple directory name without separators. path.posix.join does not normalize | |
| // backslashes, so we must use path.join (which handles OS-native separators) | |
| // and then normalize to POSIX format. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The parameterized test covers backslashes in the
sourcepath, but it doesn’t cover trailing separators (e.g.owner/repo:packages\\shared\\/owner/repo:packages/shared/). Those inputs are plausible (especially from Windows shells) and currently interact badly withbasePath.length + 1relative-path slicing. Consider adding trailing-slash/backslash variants here so the normalization logic is exercised and guarded against regressions.