Merged
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR fixes issues with inconsistent path separators by converting Windows-style backslashes to forward slashes in destination and relative paths.
- Updated path normalization in production code to ensure consistent file paths.
- Adjusted test assertions to compare normalized path strings.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/lib/sync-client.ts | Normalizes the generated relative and destination paths by replacing backslashes with forward slashes. |
| src/lib/sync-client.test.ts | Updates test assertions to use normalized paths and verifies that nested file paths use forward slashes. |
| for (const entry of entries) { | ||
| const fullPath = path.join(currentPath, entry.name); | ||
| const newRelativePath = path.join(relativePath, entry.name); | ||
| const newRelativePath = path.join(relativePath, entry.name).replace(/\\/g, "/"); |
There was a problem hiding this comment.
[nitpick] Consider extracting the path normalization logic into a dedicated helper function to reduce code duplication and improve maintainability, especially as similar patterns appear throughout the file.
Suggested change
| const newRelativePath = path.join(relativePath, entry.name).replace(/\\/g, "/"); | |
| const newRelativePath = this.normalizePath(path.join(relativePath, entry.name)); |
Comment on lines
61
to
+75
| expect(result.uploadedFiles).toContain( | ||
| path.join(destinationPath, "file1.txt") | ||
| path.join(destinationPath, "file1.txt").replace(/\\/g, "/") | ||
| ); | ||
| expect(result.uploadedFiles).toContain( | ||
| path.join(destinationPath, "file2.txt") | ||
| path.join(destinationPath, "file2.txt").replace(/\\/g, "/") | ||
| ); | ||
| expect(result.uploadedFiles).toContain( | ||
| path.join(destinationPath, "subdir/file3.txt") | ||
| path.join(destinationPath, "subdir/file3.txt").replace(/\\/g, "/") | ||
| ); | ||
|
|
||
| // Verify uploadFile was called for each file with correct destination paths | ||
| expect(mockGcpClient.uploadFile).toHaveBeenCalledTimes(3); | ||
| expect(mockGcpClient.uploadFile).toHaveBeenCalledWith( | ||
| path.join(tempDir, "file1.txt"), | ||
| path.join(destinationPath, "file1.txt") | ||
| path.join(destinationPath, "file1.txt").replace(/\\/g, "/") |
There was a problem hiding this comment.
[nitpick] To reduce repetition, consider using a helper function or a constant for the normalized destination path within tests, enhancing clarity and easing potential future updates.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.