Skip to content

fix path separators#10

Merged
pilvikala merged 2 commits intomainfrom
fix-windows-syncs
May 7, 2025
Merged

fix path separators#10
pilvikala merged 2 commits intomainfrom
fix-windows-syncs

Conversation

@pilvikala
Copy link
Copy Markdown
Owner

No description provided.

@pilvikala pilvikala requested a review from Copilot May 6, 2025 15:01
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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, "/");
Copy link

Copilot AI May 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[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));

Copilot uses AI. Check for mistakes.
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, "/")
Copy link

Copilot AI May 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[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.

Copilot uses AI. Check for mistakes.
@pilvikala pilvikala merged commit 93dc726 into main May 7, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants